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 2025-01-13 13:38 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-01-13 13:38 +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") 1fghi
18 assert response.status_code == 404, response.text 1fghi
19 assert response.json() == {"detail": "Item not found"} 1fghi
22@needs_py39 1eabcd
23def test_owner_error(client: TestClient): 1eabcd
24 response = client.get("/items/plumbus") 1jklm
25 assert response.status_code == 400, response.text 1jklm
26 assert response.json() == {"detail": "Owner error: Rick"} 1jklm
29@needs_py39 1eabcd
30def test_get_item(client: TestClient): 1eabcd
31 response = client.get("/items/portal-gun") 1nopq
32 assert response.status_code == 200, response.text 1nopq
33 assert response.json() == {"description": "Gun to create portals", "owner": "Rick"} 1nopq