Name | lineartest JSON |
Version |
0.4.4
JSON |
| download |
home_page | None |
Summary | A testing framework working with Starlette TestClient. |
upload_time | 2024-04-12 05:55:07 |
maintainer | None |
docs_url | None |
author | Philip Fan |
requires_python | <4.0,>=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# LinearTest
A testing framework working with Starlette TestClient.
- **Source code**: https://github.com/fanyf22/lineartest/
- **Documentation**: https://fanyf22.github.io/lineartest/
## Dependencies
```toml
python = "^3.10"
pydantic = "^2.6.4"
pyyaml = "^6.0.1"
httpx = "^0.27.0"
```
## Installing
The package is published on https://pypi.org/lineartest.
Use `pip` or similar commands to install it:
```shell
pip install lineartest
```
## Features
- `lineartest.schedule` helps you run tests one-by-one in order, and the tests run later can retrieve the results from the tests run earlier.
- `lineartest.client` helps you log the detail of a request and the response easily.
## Example
```python
from pydantic import BaseModel
from starlette.testclient import TestClient
from lineartest import LinearClient, schedule
# import your ASGI app here for testing
...
test_client = TestClient(app)
client = LinearClient(test_client)
# add `test_login` function to schedule
@schedule
def test_login(username, password):
class Response(BaseModel):
success: bool
token: str
# the parameters are the same as `TestClient`
res = client.post('/login', data={
'username': username,
'password': password
}, model=Response) # use `model` parameter to specify a response model
assert res.success
return res.token # the result will be stored by `schedule`
# add `test_resource` function to schedule
@schedule
def test_resource():
# use `schedule.get` to retrieve history result
token = schedule.get(test_login)
class Response(BaseModel):
success: bool
res = client.get('/', headers={
'Authorization': f'Bearer {token}'
}, model=Response)
assert res.success
# run the schedule
# you may pass positional or keyword arguments
schedule.run('username', password='password')
```
## License
This project is licensed under the terms of the MIT License.
Raw data
{
"_id": null,
"home_page": null,
"name": "lineartest",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Philip Fan",
"author_email": "topfyf@qq.com",
"download_url": "https://files.pythonhosted.org/packages/94/b3/bb157cc62b346472670b3cbd44208a9146fb755218a5561434300f2dba9e/lineartest-0.4.4.tar.gz",
"platform": null,
"description": "# LinearTest\nA testing framework working with Starlette TestClient.\n\n- **Source code**: https://github.com/fanyf22/lineartest/\n- **Documentation**: https://fanyf22.github.io/lineartest/\n\n## Dependencies\n\n```toml\npython = \"^3.10\"\npydantic = \"^2.6.4\"\npyyaml = \"^6.0.1\"\nhttpx = \"^0.27.0\"\n```\n\n## Installing\n\nThe package is published on https://pypi.org/lineartest.\n\nUse `pip` or similar commands to install it:\n\n```shell\npip install lineartest\n```\n\n## Features\n\n- `lineartest.schedule` helps you run tests one-by-one in order, and the tests run later can retrieve the results from the tests run earlier.\n- `lineartest.client` helps you log the detail of a request and the response easily.\n\n## Example\n\n```python\nfrom pydantic import BaseModel\nfrom starlette.testclient import TestClient\nfrom lineartest import LinearClient, schedule\n\n# import your ASGI app here for testing\n...\n\ntest_client = TestClient(app)\nclient = LinearClient(test_client)\n\n\n# add `test_login` function to schedule\n@schedule\ndef test_login(username, password):\n class Response(BaseModel):\n success: bool\n token: str\n\n # the parameters are the same as `TestClient`\n res = client.post('/login', data={\n 'username': username,\n 'password': password\n }, model=Response) # use `model` parameter to specify a response model\n\n assert res.success\n return res.token # the result will be stored by `schedule`\n\n# add `test_resource` function to schedule\n@schedule\ndef test_resource():\n # use `schedule.get` to retrieve history result\n token = schedule.get(test_login)\n\n class Response(BaseModel):\n success: bool\n\n res = client.get('/', headers={\n 'Authorization': f'Bearer {token}'\n }, model=Response)\n\n assert res.success\n\n\n# run the schedule\n# you may pass positional or keyword arguments\nschedule.run('username', password='password')\n```\n\n## License\n\nThis project is licensed under the terms of the MIT License.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A testing framework working with Starlette TestClient.",
"version": "0.4.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "588a17dd6e6c1765e90ef1b26ae1ff6ad4ac1cc5a4a5f514bdcbf57336fc6f98",
"md5": "0c8c6a2641a810639ed1932fcf360266",
"sha256": "f7d70623e7128221db7c17a9c548018c6aa9ec547d90695c0faeebbb6817f21f"
},
"downloads": -1,
"filename": "lineartest-0.4.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c8c6a2641a810639ed1932fcf360266",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 6872,
"upload_time": "2024-04-12T05:55:06",
"upload_time_iso_8601": "2024-04-12T05:55:06.057574Z",
"url": "https://files.pythonhosted.org/packages/58/8a/17dd6e6c1765e90ef1b26ae1ff6ad4ac1cc5a4a5f514bdcbf57336fc6f98/lineartest-0.4.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "94b3bb157cc62b346472670b3cbd44208a9146fb755218a5561434300f2dba9e",
"md5": "ff6cd132420cc596f033886c000d584d",
"sha256": "bfcfaae3bf5f46aea3b816c4642b25dbaddb218f3db6ad6ddb501129fa6d48db"
},
"downloads": -1,
"filename": "lineartest-0.4.4.tar.gz",
"has_sig": false,
"md5_digest": "ff6cd132420cc596f033886c000d584d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 5705,
"upload_time": "2024-04-12T05:55:07",
"upload_time_iso_8601": "2024-04-12T05:55:07.526083Z",
"url": "https://files.pythonhosted.org/packages/94/b3/bb157cc62b346472670b3cbd44208a9146fb755218a5561434300f2dba9e/lineartest-0.4.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-12 05:55:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "lineartest"
}