No project description provided
Project description
jj-district42
Installation
pip3 install jj-district42
Usage
import asyncio
import jj
from httpx import AsyncClient
from jj.mock import mocked
from jj_district42 import HistorySchema
from valera import validate_or_fail
async def main():
matcher = jj.match("GET", "/users")
response = jj.Response(status=200, json=[])
async with mocked(matcher, response) as mock:
async with AsyncClient() as client:
params = {"user_id": 1}
await client.get("http://localhost:8080/users", params=params)
assert validate_or_fail(
HistorySchema % [
{
"request": {
"method": "GET",
"path": "/users",
# equals (exact match)
"params": {"user_id": "1"},
},
"response": {
"status": 200,
# contains
"headers": [
...,
["Content-Type", "application/json"],
...
],
"body": b"[]",
}
}
],
mock.history
)
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jj-district42-0.2.0.tar.gz
(17.0 kB
view hashes)
Built Distribution
Close
Hashes for jj_district42-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35e7505e46d1c03138c052d4702cef4ff370de9817ca1944ae861e31a424f1ec |
|
MD5 | 4f88b3bec248e0809b7f4093c02e2b13 |
|
BLAKE2b-256 | 8e6e6ff28342aa9c8c2bcdc071d5c6b1e29a46b51180d4e71fda3b87b46be6bd |