Changeset View
Changeset View
Standalone View
Standalone View
swh/core/api/tests/test_async.py
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | async def test_get_simple(cli) -> None: | ||||
assert value == "toor" | assert value == "toor" | ||||
async def test_get_server_exception(cli) -> None: | async def test_get_server_exception(cli) -> None: | ||||
resp = await cli.get("/server_exception") | resp = await cli.get("/server_exception") | ||||
assert resp.status == 500 | assert resp.status == 500 | ||||
data = await resp.read() | data = await resp.read() | ||||
data = msgpack.unpackb(data, raw=False) | data = msgpack.unpackb(data, raw=False) | ||||
assert data["exception"]["type"] == "TestServerException" | assert data["type"] == "TestServerException" | ||||
async def test_get_client_error(cli) -> None: | async def test_get_client_error(cli) -> None: | ||||
resp = await cli.get("/client_error") | resp = await cli.get("/client_error") | ||||
assert resp.status == 400 | assert resp.status == 400 | ||||
data = await resp.read() | data = await resp.read() | ||||
data = msgpack.unpackb(data, raw=False) | data = msgpack.unpackb(data, raw=False) | ||||
assert data["exception"]["type"] == "TestClientError" | assert data["type"] == "TestClientError" | ||||
async def test_get_simple_nego(cli) -> None: | async def test_get_simple_nego(cli) -> None: | ||||
for ctype in ("x-msgpack", "json"): | for ctype in ("x-msgpack", "json"): | ||||
resp = await cli.get("/", headers={"Accept": "application/%s" % ctype}) | resp = await cli.get("/", headers={"Accept": "application/%s" % ctype}) | ||||
assert resp.status == 200 | assert resp.status == 200 | ||||
check_mimetype(resp.headers["Content-Type"], "application/%s" % ctype) | check_mimetype(resp.headers["Content-Type"], "application/%s" % ctype) | ||||
assert (await decode_request(resp)) == "toor" | assert (await decode_request(resp)) == "toor" | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |