Coverage for tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py: 100%
23 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1import pytest 1eabcd
2from fastapi.testclient import TestClient 1eabcd
4from ...utils import needs_py39 1eabcd
7@pytest.fixture(name="client") 1eabcd
8def get_client(): 1eabcd
9 from docs_src.dependencies.tutorial008b_an_py39 import app 1abcd
11 client = TestClient(app) 1abcd
12 return client 1abcd
15@needs_py39 1eabcd
16def test_get_no_item(client: TestClient): 1eabcd
17 response = client.get("/items/foo") 1abcd
18 assert response.status_code == 404, response.text 1abcd
19 assert response.json() == {"detail": "Item not found"} 1abcd
22@needs_py39 1eabcd
23def test_owner_error(client: TestClient): 1eabcd
24 response = client.get("/items/plumbus") 1abcd
25 assert response.status_code == 400, response.text 1abcd
26 assert response.json() == {"detail": "Owner error: Rick"} 1abcd
29@needs_py39 1eabcd
30def test_get_item(client: TestClient): 1eabcd
31 response = client.get("/items/portal-gun") 1abcd
32 assert response.status_code == 200, response.text 1abcd
33 assert response.json() == {"description": "Gun to create portals", "owner": "Rick"} 1abcd