Coverage for tests/test_tutorial/test_additional_status_codes/test_tutorial001_an_py39.py: 100%

18 statements  

« 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

3 

4from ...utils import needs_py39 1eabcd

5 

6 

7@pytest.fixture(name="client") 1eabcd

8def get_client(): 1eabcd

9 from docs_src.additional_status_codes.tutorial001_an_py39 import app 1abcd

10 

11 client = TestClient(app) 1abcd

12 return client 1abcd

13 

14 

15@needs_py39 1eabcd

16def test_update(client: TestClient): 1eabcd

17 response = client.put("/items/foo", json={"name": "Wrestlers"}) 1abcd

18 assert response.status_code == 200, response.text 1abcd

19 assert response.json() == {"name": "Wrestlers", "size": None} 1abcd

20 

21 

22@needs_py39 1eabcd

23def test_create(client: TestClient): 1eabcd

24 response = client.put("/items/red", json={"name": "Chillies"}) 1abcd

25 assert response.status_code == 201, response.text 1abcd

26 assert response.json() == {"name": "Chillies", "size": None} 1abcd