Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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
@user_passes_test(methodcaller('has_perm', 'testruns.add_tcmsenvrunvaluemap'))
def link_env_value(request, run_ids, env_value_ids):
"""Link 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.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_testruntag'))
def remove_tag(request, run_ids, tags):
"""Remove a tag from a run.
: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.
:rtype: list
Example::
# Remove tag 'foo' from run 1
>>> TestRun.remove_tag(1, 'foo')
@user_passes_test(methodcaller('has_perm', 'auth.change_user'))
def join(request, username, groupname):
"""Add user to a group specified by name.
:param str username: user name.
:param str groupname: group name to add given user name.
:raise PermissionDenied: if the request has no permission to add a user to
a group.
:raise Object.DoesNotExist: if user name or group name does not exist.
Example::
User.join('username', 'groupname')
"""
try:
user = User.objects.get(username=username)