wiki:TestManagerForTracPluginPythonApi

Version 2 (modified by seccanj, 4 years ago) (diff)

--

Test Manager for Trac Plugin - The Python API

TODO: The main API is to be described. What follows is a subset of functions recently requested by Users.

Getting all the Tickets related to a Test Case

Since: 1.4.1

You now have the ability to programmatically get all of the tickets that have been (explicitly) opened against a test case.

From a TestCase object, you can list the tickets opened against it in any test plan.

From a TestCaseInPlan object, you can list the tickets opened against the test case in the specific plan.

from testmanager.model import TestCase, TestCaseInPlan

tc = TestCase(self.env, id, path)
for t in tc.get_related_tickets():
    # t is the ticket ID

tc = TestCaseInPlan(self.env, id, planid, path)
for t in tc.get_related_tickets():
    # t is the ticket ID

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.

Registering listeners to Test objects lifecycle events

Being based on the Generic Persistent Class plugin, every test object supports a listener interface for components interested in test lifecycle events.

Note: The same stands for any workflow you may have attached to our test objects, by means of the Generic Workflow Engine. Anyway, in this case a specific listener interface has been provided.

To register a listener inside the Generic Persistent Class framework, follow this guide.