Coverage for tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py: 100%

11 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 docs_src.behind_a_proxy.tutorial002 import app 1abcde

4 

5client = TestClient(app) 1abcde

6 

7 

8def test_main(): 1abcde

9 response = client.get("/app") 1abcde

10 assert response.status_code == 200 1abcde

11 assert response.json() == {"message": "Hello World", "root_path": "/api/v1"} 1abcde

12 

13 

14def test_openapi(): 1abcde

15 response = client.get("/openapi.json") 1abcde

16 assert response.status_code == 200 1abcde

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

18 "openapi": "3.1.0", 

19 "info": {"title": "FastAPI", "version": "0.1.0"}, 

20 "paths": { 

21 "/app": { 

22 "get": { 

23 "summary": "Read Main", 

24 "operationId": "read_main_app_get", 

25 "responses": { 

26 "200": { 

27 "description": "Successful Response", 

28 "content": {"application/json": {"schema": {}}}, 

29 } 

30 }, 

31 } 

32 } 

33 }, 

34 "servers": [{"url": "/api/v1"}], 

35 }