Debian Codegraph @

tests/test_swagger_ui_init_oauth.py

raw
1 from fastapi import FastAPI
2 from fastapi.testclient import TestClient
3
4 swagger_ui_init_oauth = {"clientId": "the-foo-clients", "appName": "The Predendapp"}
5
6 app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth)
7
8
9 @app.get("/items/")
10 async def read_items():
11 return {"id": "foo"}
12
13
14 client = TestClient(app)
15
16
17 def test_swagger_ui():
18 response = client.get("/docs")
19 assert response.status_code == 200, response.text
20 print(response.text)
21 assert "ui.initOAuth" in response.text
22 assert '"appName": "The Predendapp"' in response.text
23 assert '"clientId": "the-foo-clients"' in response.text
24
25
26 def test_response():
27 response = client.get("/items/")
28 assert response.json() == {"id": "foo"}