TestRail client implementing all API v2.
Project description
TestRail client by BestDoctor
Implements API v2 for TestRail.
Installation
pip install best_testrail_client
Prerequisites
-
Enabled API in your TestRail project.
-
Generated API key.
Usage
from best_testrail_client.client import TestRailClient
from best_testrail_client.enums import BaseResultStatus
from best_testrail_client.models.result import Result
from best_testrail_client.models.run import Run
# Client initialization
project_url = 'https://<YOUR_PROJECT>.testrail.io/' # or other URL for self-hosted
login = '<account email>'
api_token = '<generated API token>'
client = TestRailClient(project_url, login, api_token)
# Create Test Run
new_run = Run(
name='Test Run from API',
include_all=False,
case_ids=[1, 2, 3],
)
created_run = client.runs.add_run(run=new_run, project_id=1)
# You can set global Project ID
client.set_project_id(project_id=2)
# Add results for run
results = [
Result(status_id=BaseResultStatus.PASSED.value, case_id=1, comment='Passed test'),
Result(status_id=BaseResultStatus.FAILED.value, case_id=2, comment='Failed test'),
Result(status_id=6, case_id=3, comment='Waiting test'), # Custom status
]
client.results.add_results_for_cases(run_id=created_run.id, results=results)
# Close run
client.runs.close_run(run_id=created_run.id)
Custom attributes
Custom attributes are stored in custom
dictionary attribute in models.
It stores all data from API and converts it back.
from best_testrail_client.client import TestRailClient
# Client initialization
project_url = 'https://<YOUR_PROJECT>.testrail.io/' # or other URL for self-hosted
login = '<account email>'
api_token = '<generated API token>'
client = TestRailClient(project_url, login, api_token)
created_run = client.runs.get_run(run_id=1)
"""
API response looks like:
{
...
'refs': 'SAN-1',
'custom_status1_count': 0,
'custom_status2_count': 0,
'custom_status3_count': 0,
'custom_status4_count': 0,
'custom_status5_count': 0,
'custom_status6_count': 0,
'custom_status7_count': 0,
'description': null,
...
}
It is now stored in custom attribute:
created_run.custom == {
'custom_status1_count': 0,
'custom_status2_count': 0,
'custom_status3_count': 0,
'custom_status4_count': 0,
'custom_status5_count': 0,
'custom_status6_count': 0,
'custom_status7_count': 0,
}
"""
Contributing
We would love you to contribute to our project. It's simple:
- Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
- Create a pull request. Make sure all checks are green.
- Fix review comments if any.
- Be awesome.
Here are useful tips:
- You can run all checks and tests with
make check
. Please do it before TravisCI does. - We use BestDoctor python styleguide.
- We respect Django CoC. Make soft, not bullshit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
best_testrail_client-0.0.2.tar.gz
(21.3 kB
view hashes)
Built Distribution
Close
Hashes for best_testrail_client-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39c9611f1514aa29f692894d81ecfdd5c4d44640dabdcef1be12c1c86db891e2 |
|
MD5 | 50ac37570c9e8784b0252d7d5802f8c6 |
|
BLAKE2b-256 | ced0221736d001d7c2246b56eb884e6cc3244d7af829f8b7cdeaf9c0b44c9c84 |
Close
Hashes for best_testrail_client-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8a30cd3e512887e66cda73b3460af516d29b3fa4d4e1a15fe32a50c3ba949c |
|
MD5 | 422b2f8c2b653ad0a64793d1d7388bd5 |
|
BLAKE2b-256 | 9a2d3f7369e5e4d0ed48423dbc9a56c3d4a12ae08512e73554763093ef60a673 |