# Python Client library for OpenTMI
[![CI Pipeline](https://github.com/OpenTMI/opentmi-pyclient/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenTMI/opentmi-pyclient/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/OpenTMI/opentmi-pyclient/badge.svg)](https://coveralls.io/github/OpenTMI/opentmi-pyclient)
[![PyPI version](https://badge.fury.io/py/opentmi-client.svg)](https://badge.fury.io/py/opentmi-client)
This is the Python client library for [OpenTMI](https://github.com/opentmi/opentmi).
## installation
To install, simply use `pip`:
`$ pip install --upgrade opentmi-client`
See the [Developers Guide](development.md) if you want to develop this library.
## Command Line Interface
Library provides Command line Interface to communicate with OpenTMI -backend
```
$ opentmi --help
usage: opentmi [-h] [-v] [-s] [--host HOST] [--user USER]
[--password PASSWORD] [--token TOKEN]
[--token_service TOKEN_SERVICE] [-p PORT]
<subcommand> ...
optional arguments:
-h, --help show this help message and exit
-v verbose level... repeat up to three times.
-s, --silent Silent - only errors will be printed
--host HOST OpenTMI host, default: localhost
--user USER username
--password PASSWORD password
--token TOKEN Authentication token
--token_service TOKEN_SERVICE
Optional authentication service
-p PORT, --port PORT OpenTMI port
subcommand:
<subcommand> sub-command help
version Display version information
list List something
store Create something
```
example:
```
opentmi --host localhost --port 3000 --list --testcases 1
```
## Python API
```
from opentmi_client import OpenTmiClient, Result, Event
client = Client("https://127.0.0.1")
client.login_with_access_token("my-github-access-token")
# post result
result = Result()
result.tcid = "test-case-a"
result.verdict = "pass"
client.post_result(result)
# post event
event = Event()
event.msgid = "ALLOCATED"
event.priority.level = "info",
event.ref.resource = "5697740f956cd2fd35c69062"
client.post_event(event)
```
See more examples from [here](https://github.com/OpenTMI/opentmi-pyclient/tree/master/examples).
Server side Result schema can be found from [here](https://github.com/OpenTMI/opentmi/blob/master/app/models/results.js#L15).
and Test case schema is available [here](https://github.com/OpenTMI/opentmi/blob/master/app/models/testcase.js).
**notes**
* `tcid` -field have to be unique for each test cases.
* There is couple mandatory fields by default: `tcid` and `exec.verdict`. Allowed values for result verdict is: `pass`, `fail`, `inconclusive`, `blocked` and `error`. `upload_results()` -function also create test case document if it doesn't exists in database.
## Authentication
There are multiple options to authenticate:
* use `Client.login(<username>, <password>)`
* use `Client.login_with_access_token(<token>, [<service>])`
* service are optional and supported values depend on server support.
By default `github` is in use.
* Use environment variables (tries login automatically when constructor is called):
* Using username and password: `OPENTMI_USERNAME` and `OPENTMI_PASSWORD` or
* Using github access token: `OPENTMI_GITHUB_ACCESS_TOKEN`
* use token in host like `http://<token>@localhost`
## LICENSE
[MIT](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/OpenTMI/opentmi-pyclient.git",
"name": "opentmi-client",
"maintainer": "Jussi Vatjus-Anttila",
"docs_url": null,
"requires_python": null,
"maintainer_email": "jussiva@gmail.com",
"keywords": "opentmi ci cd api sdk",
"author": "Jussi Vatjus-Anttila",
"author_email": "jussiva@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/82/38/0fe421bef4e2c2897b90b9345eca569be22211afe00185ecc18582dbd0bb/opentmi_client-0.11.0.tar.gz",
"platform": null,
"description": "# Python Client library for OpenTMI\n\n[![CI Pipeline](https://github.com/OpenTMI/opentmi-pyclient/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenTMI/opentmi-pyclient/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/OpenTMI/opentmi-pyclient/badge.svg)](https://coveralls.io/github/OpenTMI/opentmi-pyclient)\n[![PyPI version](https://badge.fury.io/py/opentmi-client.svg)](https://badge.fury.io/py/opentmi-client)\n\nThis is the Python client library for [OpenTMI](https://github.com/opentmi/opentmi).\n\n## installation\n\nTo install, simply use `pip`:\n\n`$ pip install --upgrade opentmi-client`\n\nSee the [Developers Guide](development.md) if you want to develop this library.\n\n## Command Line Interface\n\nLibrary provides Command line Interface to communicate with OpenTMI -backend\n\n```\n$ opentmi --help\nusage: opentmi [-h] [-v] [-s] [--host HOST] [--user USER]\n [--password PASSWORD] [--token TOKEN]\n [--token_service TOKEN_SERVICE] [-p PORT]\n <subcommand> ...\n\noptional arguments:\n -h, --help show this help message and exit\n -v verbose level... repeat up to three times.\n -s, --silent Silent - only errors will be printed\n --host HOST OpenTMI host, default: localhost\n --user USER username\n --password PASSWORD password\n --token TOKEN Authentication token\n --token_service TOKEN_SERVICE\n Optional authentication service\n -p PORT, --port PORT OpenTMI port\n\nsubcommand:\n <subcommand> sub-command help\n version Display version information\n list List something\n store Create something\n```\n\nexample:\n```\nopentmi --host localhost --port 3000 --list --testcases 1\n```\n\n## Python API\n\n```\nfrom opentmi_client import OpenTmiClient, Result, Event\nclient = Client(\"https://127.0.0.1\")\nclient.login_with_access_token(\"my-github-access-token\")\n\n# post result\nresult = Result()\nresult.tcid = \"test-case-a\"\nresult.verdict = \"pass\"\nclient.post_result(result)\n\n# post event\nevent = Event()\nevent.msgid = \"ALLOCATED\"\nevent.priority.level = \"info\",\nevent.ref.resource = \"5697740f956cd2fd35c69062\"\nclient.post_event(event)\n```\n\nSee more examples from [here](https://github.com/OpenTMI/opentmi-pyclient/tree/master/examples).\n\nServer side Result schema can be found from [here](https://github.com/OpenTMI/opentmi/blob/master/app/models/results.js#L15).\nand Test case schema is available [here](https://github.com/OpenTMI/opentmi/blob/master/app/models/testcase.js).\n\n**notes**\n\n* `tcid` -field have to be unique for each test cases.\n* There is couple mandatory fields by default: `tcid` and `exec.verdict`. Allowed values for result verdict is: `pass`, `fail`, `inconclusive`, `blocked` and `error`. `upload_results()` -function also create test case document if it doesn't exists in database.\n\n## Authentication\n\nThere are multiple options to authenticate:\n* use `Client.login(<username>, <password>)`\n* use `Client.login_with_access_token(<token>, [<service>])`\n * service are optional and supported values depend on server support.\n By default `github` is in use.\n* Use environment variables (tries login automatically when constructor is called):\n * Using username and password: `OPENTMI_USERNAME` and `OPENTMI_PASSWORD` or\n * Using github access token: `OPENTMI_GITHUB_ACCESS_TOKEN`\n* use token in host like `http://<token>@localhost`\n\n## LICENSE\n\n[MIT](LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "opentmi-client",
"version": "0.11.0",
"project_urls": {
"Homepage": "https://github.com/OpenTMI/opentmi-pyclient.git"
},
"split_keywords": [
"opentmi",
"ci",
"cd",
"api",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "806bfad54d21ac93f3747cb15875b53891c549a22b5dcea47e7da2ca82a6c2d9",
"md5": "89f1dbb78d6bbba6796f1b70759e0f43",
"sha256": "51903db772107c98343334217a9dab9d00334abe018632c8a56868aacaa54387"
},
"downloads": -1,
"filename": "opentmi_client-0.11.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "89f1dbb78d6bbba6796f1b70759e0f43",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 43136,
"upload_time": "2024-10-05T17:24:39",
"upload_time_iso_8601": "2024-10-05T17:24:39.405196Z",
"url": "https://files.pythonhosted.org/packages/80/6b/fad54d21ac93f3747cb15875b53891c549a22b5dcea47e7da2ca82a6c2d9/opentmi_client-0.11.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "82380fe421bef4e2c2897b90b9345eca569be22211afe00185ecc18582dbd0bb",
"md5": "379b0f554cccbbea040d6416cb9009ae",
"sha256": "1511b445fc5aa2582ec940829e4f0cb0522ac859d93975b02d7062565589fe83"
},
"downloads": -1,
"filename": "opentmi_client-0.11.0.tar.gz",
"has_sig": false,
"md5_digest": "379b0f554cccbbea040d6416cb9009ae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 35599,
"upload_time": "2024-10-05T17:24:40",
"upload_time_iso_8601": "2024-10-05T17:24:40.474611Z",
"url": "https://files.pythonhosted.org/packages/82/38/0fe421bef4e2c2897b90b9345eca569be22211afe00185ecc18582dbd0bb/opentmi_client-0.11.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-05 17:24:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OpenTMI",
"github_project": "opentmi-pyclient",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
">=",
"2.13.0"
]
]
},
{
"name": "jsonmerge",
"specs": []
},
{
"name": "six",
"specs": []
},
{
"name": "pydash",
"specs": []
},
{
"name": "junitparser",
"specs": [
[
"<",
"2.0.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"<",
"2"
],
[
">=",
"1.26.0"
]
]
}
],
"lcname": "opentmi-client"
}