Coverage for tests/test_tutorial/test_behind_a_proxy/test_tutorial004.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.tutorial004 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 {
23 "url": IsOneOf(
24 "https://stag.example.com/",
25 # TODO: remove when deprecating Pydantic v1
26 "https://stag.example.com",
27 ),
28 "description": "Staging environment",
29 },
30 {
31 "url": IsOneOf(
32 "https://prod.example.com/",
33 # TODO: remove when deprecating Pydantic v1
34 "https://prod.example.com",
35 ),
36 "description": "Production environment",
37 },
38 ],
39 "paths": {
40 "/app": {
41 "get": {
42 "summary": "Read Main",
43 "operationId": "read_main_app_get",
44 "responses": {
45 "200": {
46 "description": "Successful Response",
47 "content": {"application/json": {"schema": {}}},
48 }
49 },
50 }
51 }
52 },
53 }