Coverage for tests / test_tutorial / test_behind_a_proxy / test_tutorial004.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi.testclient import TestClient 1abcd
2from inline_snapshot import snapshot 1abcd
4from docs_src.behind_a_proxy.tutorial004_py310 import app 1abcd
6client = TestClient(app) 1abcd
9def test_main(): 1abcd
10 response = client.get("/app") 1efg
11 assert response.status_code == 200 1efg
12 assert response.json() == {"message": "Hello World", "root_path": "/api/v1"} 1efg
15def test_openapi_schema(): 1abcd
16 response = client.get("/openapi.json") 1hij
17 assert response.status_code == 200 1hij
18 assert response.json() == snapshot( 1hij
19 {
20 "openapi": "3.1.0",
21 "info": {"title": "FastAPI", "version": "0.1.0"},
22 "servers": [
23 {
24 "url": "https://stag.example.com",
25 "description": "Staging environment",
26 },
27 {
28 "url": "https://prod.example.com",
29 "description": "Production environment",
30 },
31 ],
32 "paths": {
33 "/app": {
34 "get": {
35 "summary": "Read Main",
36 "operationId": "read_main_app_get",
37 "responses": {
38 "200": {
39 "description": "Successful Response",
40 "content": {"application/json": {"schema": {}}},
41 }
42 },
43 }
44 }
45 },
46 }
47 )