| 1 | = The Python API = |
| 2 | |
| 3 | TODO: The main API is to be described. What follows is a subset of functions recently requested by Users. |
| 4 | |
| 5 | == Getting all the Tickets related to a Test Case == |
| 6 | |
| 7 | '''Since: 1.4.1''' |
| 8 | |
| 9 | You now have the ability to programmatically get all of the tickets that have been (explicitly) opened against a test case. |
| 10 | |
| 11 | From a TestCase object, you can list the tickets opened against it in any test plan. |
| 12 | |
| 13 | From a TestCaseInPlan object, you can list the tickets opened against the test case in the specific plan. |
| 14 | |
| 15 | {{{ |
| 16 | from testmanager.model import TestCase, TestCaseInPlan |
| 17 | |
| 18 | tc = TestCase(self.env, id, path) |
| 19 | for t in tc.get_related_tickets(): |
| 20 | # t is the ticket ID |
| 21 | |
| 22 | tc = TestCaseInPlan(self.env, id, planid, path) |
| 23 | for t in tc.get_related_tickets(): |
| 24 | # t is the ticket ID |
| 25 | }}} |
| 26 | |
| 27 | This is achieved by adding two custom fields to the ticket object, named 'testcaseid' for the test case ID, and 'planid' for the test plan ID. |
| 28 | |
| 29 | == Registering listeners to Test objects lifecycle events == |
| 30 | |
| 31 | Being based on the [wiki:TestManagerForTracPluginGenericClass Generic Persistent Class plugin], every test object supports a listener interface for components interested in test lifecycle events. |
| 32 | |
| 33 | Note: The same stands for any workflow you may have attached to our test objects, by means of the [wiki:TestManagerForTracPluginWorkflow Generic Workflow Engine]. Anyway, in this case a [wiki:TestManagerForTracPluginWorkflow#IWorkflowTransitionListener specific listener interface] has been provided. |
| 34 | |
| 35 | To register a listener inside the Generic Persistent Class framework, follow [wiki:TestManagerForTracPluginGenericClass#IGenericObjectChangeListener-Registeringlistenerstoobjectslifecycleevents this guide]. |