Coverage for tests/test_tutorial/test_dependencies/test_tutorial008b.py: 100%
15 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
1from fastapi.testclient import TestClient 1abcde
3from docs_src.dependencies.tutorial008b import app 1abcde
5client = TestClient(app) 1abcde
8def test_get_no_item(): 1abcde
9 response = client.get("/items/foo") 1abcde
10 assert response.status_code == 404, response.text 1abcde
11 assert response.json() == {"detail": "Item not found"} 1abcde
14def test_owner_error(): 1abcde
15 response = client.get("/items/plumbus") 1abcde
16 assert response.status_code == 400, response.text 1abcde
17 assert response.json() == {"detail": "Owner error: Rick"} 1abcde
20def test_get_item(): 1abcde
21 response = client.get("/items/portal-gun") 1abcde
22 assert response.status_code == 200, response.text 1abcde
23 assert response.json() == {"description": "Gun to create portals", "owner": "Rick"} 1abcde