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