test_test.py
1 from httpx import AsyncClient 2 3 4 async def test__test(client: AsyncClient) -> None: 5 response = await client.get("/test") 6 assert response.status_code == 200 7 assert response.json() == {"result": "hello world"} 8 9 10 async def test__auth_static__unauthorized(client: AsyncClient) -> None: 11 response = await client.get("/auth/static") 12 assert response.status_code == 401 13 14 15 async def test__auth_static__authorized(auth_client: AsyncClient) -> None: 16 response = await auth_client.get("/auth/static") 17 assert response.status_code == 200 18 assert response.json() == [1, 2, 3] 19 20 21 async def test__auth_jwt__unauthorized(client: AsyncClient) -> None: 22 response = await client.get("/auth/jwt") 23 assert response.status_code == 401 24 25 26 async def test__auth_jwt__authorized(auth_client: AsyncClient) -> None: 27 response = await auth_client.get("/auth/jwt") 28 assert response.status_code == 200 29 assert response.json() == {"test": [1, 2, 3, 4, 5], "data": {"foo": "bar"}}