Python module to use Testspace API and client. Provides a python object that can manage url, Testspace token, project name and space name in addition to providing convience functions to push results and do most common api requests.
Install from PyPi
$ pip install testspace-pythonTo use the module the items listed below are needed.
- Organization url (organization.testspace.com)
- Testspace token
- Project name (optional)
- Space name (optional)
Project and Space names do not have to be set on instantiation of the Testspace object and can be passed as parameters to any function call that requires them. They can also be passed into any of the functions to override, but not update the objects stored values.
from testspace import testspace as ts
token = "access token"
url = "organization.testspace.com"
project = "project name"
space= "space name"
testspace = ts.Testspace(token=token, url=url, project=project, space=space)
Provides a python wrapper to use the Testspace client for pushing content to Testspace.
testspace = ts.Testspace(token=token, url=url, project=project, space=space)
testspace.push("testresults.xml", result_name="build.1", how="full")
The following Testspace client option are supported as parameters to the push function.
| Client Option | Function Parameter |
|---|---|
| file | file |
| how | how |
| result name | result_name |
| build-url | build_url |
| repo | repo |
| link | link |
| message | message |
Provides a python wrapper to using the Testspace API. The available functions mirror the structure of the API endpoints, with GET, POST, PATCH, and DELETE options available as appropriate for the endpoint. Where names in addition to id's are supported in the API, they can be used interchangably here as well. All functions return any JSON response as a result of the request see Testspace API help for details of the response. For any Testspace API that return a list, the page size default limit of 30 is used, for any of these function the limit parameter can be added with an integer value for the max number of returned items.
testspace.get_projects(limit=30)
testspace.get_project(project=None)
payload = {"name": "new project name"}
testspace.post_projects(payload=payload)
payload = {"description": "Awesome project"}
testspace.patch_project(payload, project=None):
testspace.delete_project(project=None)
testspace.get_spaces(project=None, limit=30)
testspace.get_space(project=None, space=None)
payload = {"name": "new space name"}
testspace.post_spaces(payload=payload, project=None)
payload = {"description": "Awesome project"}
testspace.patch_project(payload, project=None, space=None):
testspace.delete_space(project=None, space=None)
testspace.get_results(project=None, space=None, limit=30)
testspace.get_result(result, project=None, space=None)
testspace.get_result_failures(result, project=None, space=None, limit=30)
# contents_path is used to obtain contents that are not at the root of the result
testspace.get_result_contents(result, contents_path=None, project=None, space=None, limit=30)
# metric must be id as name resolution is not supported for this.
testspace.get_metric_datasets(metric, project=None, space=None, limit=30)
testspace.get_metrics(project=None, space=None, limit=30)
# metric must be id as name resolution is not supported for this.
testspace.get_metric(metric, project=None, space=None, limit=30)
payload = {
"name": "MyMetric",
"data_source": "/path/to/suite[dataset_label]"
}
testspace.post_metrics(payload)
payload = {
"data_source": "/path/to/suite[dataset_label]"
}
testspace.patch_metrics(payload, metric)
testspace.delete_metric(metric)
How to run lint and tests:
$ flake8 .
$ black .
$ pytest
To use pre-commit:
$ git add *
# to apply to staged files
$ pre-commit run
# restage if changes
$ git add *
# to run on commits
$ pre-commit install
$ git commit -m 'Initial commit'
(package originally created by python-pkg-cookiecutter)