Coverage for tests/test_validate_response_recursive/test_validate_response_recursive_pv2.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi.testclient import TestClient 1abcde

2 

3from ..utils import needs_pydanticv2 1abcde

4 

5 

6@needs_pydanticv2 1abcde

7def test_recursive(): 1abcde

8 from .app_pv2 import app 1abcde

9 

10 client = TestClient(app) 1abcde

11 response = client.get("/items/recursive") 1abcde

12 assert response.status_code == 200, response.text 1abcde

13 assert response.json() == { 1abcde

14 "sub_items": [{"name": "subitem", "sub_items": []}], 

15 "name": "item", 

16 } 

17 

18 response = client.get("/items/recursive-submodel") 1abcde

19 assert response.status_code == 200, response.text 1abcde

20 assert response.json() == { 1abcde

21 "name": "item", 

22 "sub_items1": [ 

23 { 

24 "name": "subitem", 

25 "sub_items2": [ 

26 { 

27 "name": "subsubitem", 

28 "sub_items1": [{"name": "subsubsubitem", "sub_items2": []}], 

29 } 

30 ], 

31 } 

32 ], 

33 }