Test Cases
TestCase
- class tcms.testcases.models.TestCase(case_id, create_date, is_automated, is_automated_proposed, script, arguments, extra_link, summary, requirement, alias, estimated_time, notes, case_status, category, priority, author, default_tester, reviewer)
- exception DoesNotExist
- exception MultipleObjectsReturned
- add_component(component: Component)
Add a component
Relationship between case and component is unique. A same component with same pk is not added.
- Parameters:
component (
Component
) – component to be added.- Returns:
the object representing relationship between this case and the component. If component is already added to this case, nothing will happen and
None
will be returned.- Return type:
TestCaseComponent
.
- add_issue(issue_key, issue_tracker, summary=None, description=None, case_run=None, link_external_tracker=False)
Add issue to case or case run
- Parameters:
issue_key (str) – issue key to add.
issue_tracker (
IssueTracker
) – to which the issue is added.summary (str) – issue’s summary. It’s optional.
description (str) – a longer description for the issue. It’s optional.
case_run (
TestCaseRun
) – If specified, that means issue is added to a test case run and also associated with this case. If omitted, it just means issue is added to this case only.link_external_tracker (bool) – whether to add the issue to issue tracker’s external tracker just after issue is added. Default to not to do that.
- Returns:
newly created issue. If issue already exists (checking the existence of issue key), nothing changes and just return immediately with None.
- Return type:
Issue
- Raises:
ValueError – if passed case run is not associated with this case.
Changed in version 4.2:
bug_id
is replaced withissue_key
.bug_system_id
is replaced withissue_tracker
.
- clear_estimated_time()
Converts a integer to time
- clone(to_plans, author=None, default_tester=None, source_plan=None, copy_attachment=True, copy_component=True, component_initial_owner=None)
Clone this case to plans
- Parameters:
to_plans (list[TestPlan]) – list of test plans this case will be cloned to.
author (django.contrib.auth.models.User or None) – set the author for the cloned test case. If omitted, original author will be used.
default_tester (django.contrib.auth.models.User or None) – set the default tester for the cloned test case. If omitted, original author will be used.
source_plan (TestPlan or None) – a test plan this case belongs to. If set, sort key of the relationship between this case and this plan will be set to the new relationship of cloned case and destination plan. Otherwise, new sort key will be calculated from the destination plan.
copy_attachment (bool) – whether to copy attachments.
copy_component (bool) – whether to copy components.
component_initial_owner (django.contrib.auth.models.User or None) – the initial owner of copied component. This argument is only used when
copy_component
is set to True.
- Returns:
the cloned test case
- Return type:
- classmethod create(author, values, plans=None)
Create the case element based on models/forms.
- remove_issue(issue_key, case_run=None)
Remove issue from this case or case run together
- Parameters:
issue_key (str) – Issue key to be removed.
case_run (
TestCaseRun
or int) – object of TestCaseRun or an integer representing a test case run pk. If omitted, only remove issue key from this case.
- Returns:
True if issue is removed, otherwise False is returned.
- Return type:
- Raises:
TypeError – if type of argument
case_run
is not recognized.ValueError – if test case run represented by argument
case_run
is not associated with this case.
- classmethod search(query: Dict[str, Any], plan: int | None = None) QuerySet
List the cases with request
- classmethod to_xmlrpc(query=None)
Convert the query set for XMLRPC
- transition_to_plans(to_plans, author=None, default_tester=None, source_plan=None)
Transition this case to other plans
This method will link this case to specified test plans and no change to the original relationship between this case and other test plans it was associated with.
- Parameters:
to_plans (list[TestPlan]) – the test plans this case is transitioned to.
author (django.contrib.auth.models.User or None) – same as the argument
author
ofTestCase.clone()
.default_tester (django.contrib.auth.models.User or None) – same as the argument
default_tester
ofTestCase.clone()
.source_plan (TestPlan or None) – same as the argument
source_plan
ofTestCase.clone()
.
- Returns:
the updated version of this case.
- Return type: