Coverage for tests/test_tutorial/test_behind_a_proxy/test_tutorial001.py: 100%
11 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi.testclient import TestClient 1abcdef
3from docs_src.behind_a_proxy.tutorial001 import app 1abcdef
5client = TestClient(app, root_path="/api/v1") 1abcdef
8def test_main(): 1abcdef
9 response = client.get("/app") 1ghijkl
10 assert response.status_code == 200 1ghijkl
11 assert response.json() == {"message": "Hello World", "root_path": "/api/v1"} 1ghijkl
14def test_openapi(): 1abcdef
15 response = client.get("/openapi.json") 1mnopqr
16 assert response.status_code == 200 1mnopqr
17 assert response.json() == { 1mnopqr
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 }