Skip to content

Programmatic building of TestRail data-structures written in Python

License

Notifications You must be signed in to change notification settings

PandoraMedia/testrail-data-model

Repository files navigation

TestRail Data Model

Python package PyPI Downloads PyPI - Python Version PyPI - Implementation License Coverage Status

This package provides an object-oriented representation of TestRail data using Python data classes. This object structure facilitates the development of tools which programmatically interact with a TestRail service.

This wraps the tolstislon/testrail-api project, which in turn wraps the official TestRail API spec.

Example

from testrail_api import TestRailAPI

from testrail_data_model.builder import TestRailAPIObjectBuilder
from testrail_data_model.adapter import TestRailAPIAdapter
from testrail_data_model.model import TestRailSection, TestRailCase, TestRailSuite

# From testrail-api client library
api_client = TestRailAPI(url="https://testrail-instance.com", email="email@email.org", password="password")

# Performs API requests and tracks stats
adapter = TestRailAPIAdapter(api_client=api_client)

# For building the TestRail dataclass object hierarchies (e.g. TestRailSuite)
builder = TestRailAPIObjectBuilder(adapter=adapter)

# Construct a TestRailSuite object linked to its associated TestRailSection and TestRailCase objects
suite: TestRailSuite = builder.build_suite(project_id=1, suite_id=1)

# Display the TestRailSuite object structure
for section_id, section in suite.sections.items():
   assert isinstance(section, TestRailSection)
   print("Section", section_id, section.path)
   for case_id, case in section.cases.items():
       assert isinstance(case, TestRailCase)
       print("Case", case_id, case.title)

# Show the number of API requests made
print(adapter.stats)

Authors

About

Programmatic building of TestRail data-structures written in Python

Topics

Resources

License

Stars

Watchers

Forks

Languages