Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_check_wait_without_subtasks(self):
t = Task.objects.create(
worker=self._worker,
arch=self._arch,
channel=self._channel,
owner=self._user,
state=TASK_STATES['FREE'],
)
req = _make_request(self._worker)
finished, unfinished = worker.check_wait(req, t.id)
self.assertEqual(len(finished), 0)
self.assertEqual(len(unfinished), 0)
)
child2 = Task.objects.create(
worker=self._worker,
arch=self._arch,
channel=self._channel,
owner=self._user,
method='DummyTask',
state=TASK_STATES['ASSIGNED'],
parent=parent,
)
parent.wait([child1.id])
parent = Task.objects.get(id=parent.id)
child1 = Task.objects.get(id=child1.id)
child2 = Task.objects.get(id=child2.id)
self.assertEquals(parent.waiting, True)
self.assertEquals(parent.awaited, False)
self.assertEquals(child1.waiting, False)
self.assertEquals(child1.awaited, True)
self.assertEquals(child2.waiting, False)
self.assertEquals(child2.awaited, False)
def test_wait(self):
with self.assertRaises(PermissionDenied):
worker.wait(_make_request(None, False), 1)
def test_check_wait(self):
with self.assertRaises(PermissionDenied):
worker.check_wait(_make_request(None, False), 1)
@user_passes_test(methodcaller('has_perm', 'testruns.add_testcaserun'))
def add_cases(request, run_ids, case_ids):
"""Add one or more cases to the selected test runs.
:param run_ids: give one or more run IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a run ID.
:type run_ids: int, str or list
:param case_ids: give one or more case IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a case ID.
:type case_ids: int, str or list
:return: a list which is empty on success or a list of mappings with
failure codes if a failure occured.
:rtype: list
Example::
@user_passes_test(methodcaller('has_perm', 'testruns.delete_testcaserun'))
def remove_cases(request, run_ids, case_ids):
"""Remove one or more cases from the selected test runs.
:param run_ids: give one or more run IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a run ID.
:type run_ids: int, str or list
:param case_ids: give one or more case IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a case ID.
:type case_ids: int, str or list
:return: a list which is empty on success or a list of mappings with
failure codes if a failure occured.
:rtype: list
Example::
@user_passes_test(methodcaller('has_perm', 'testruns.add_testruntag'))
def add_tag(request, run_ids, tags):
"""Add one or more tags to the selected test runs.
:param run_ids: give one or more run IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a run ID.
:type run_ids: int, str or list
:param tags: tag name or a list of tag names to remove.
:type tags: str or list
:return: a list which is empty on success or a list of mappings with
failure codes if a failure occured.
:rtype: list
Example::
# Add tag 'foobar' to run 1
@user_passes_test(methodcaller('has_perm', 'testruns.delete_tcmsenvrunvaluemap'))
def unlink_env_value(request, run_ids, env_value_ids):
"""Unlink env values to the given runs.
:param run_ids: give one or more run IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a run ID.
:type run_ids: int, str or list
:param env_value_ids: give one or more environment value IDs. It could be
an integer, a string containing comma separated IDs, or a list of int
each of them is a environment value ID.
:type env_value_ids: int, str or list
:return: a list which is empty on success or a list of mappings with
failure codes if a failure occured.
:rtype: list
Example::
@user_passes_test(methodcaller('has_perm', 'testruns.change_tcmsenvrunvaluemap'))
def env_value(request, action, run_ids, env_value_ids):
"""
Add or remove env values to the given runs, function is same as
link_env_value or unlink_env_value
:param str action: what action to do, ``add`` or ``remove``.
:param run_ids: give one or more run IDs. It could be an integer, a
string containing comma separated IDs, or a list of int each of them is
a run ID.
:type run_ids: int, str or list
:param env_value_ids: give one or more environment value IDs. It could be
an integer, a string containing comma separated IDs, or a list of int
each of them is a environment value ID.
:type env_value_ids: int, str or list
:return: a list which is empty on success or a list of mappings with
failure codes if a failure occured.
@user_passes_test(methodcaller('has_perm', 'testruns.add_testrun'))
def create(request, values):
"""Creates a new Test Run object and stores it in the database.
:param dict values: a mapping containing these data to create a test run.
* plan: (int) **Required** ID of test plan
* build: (int)/(str) **Required** ID of Build
* errata_id: (int) optional ID of Errata
* manager: (int) **Required** ID of run manager
* summary: (str) **Required**
* product: (int) **Required** ID of product
* product_version: (int) **Required** ID of product version
* default_tester: (int) optional ID of run default tester
* plan_text_version: (int) optional
* estimated_time: (str) optional, could be in format ``2h30m30s``, which is recommended or ``HH:MM:SS``.
* notes: (str) optional