Coverage for tests / test_swagger_ui_init_oauth.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from fastapi import FastAPI 1abcd

2from fastapi.testclient import TestClient 1abcd

3 

4swagger_ui_init_oauth = {"clientId": "the-foo-clients", "appName": "The Predendapp"} 1abcd

5 

6app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth) 1abcd

7 

8 

9@app.get("/items/") 1abcd

10async def read_items(): 1abcd

11 return {"id": "foo"} 1ijkl

12 

13 

14client = TestClient(app) 1abcd

15 

16 

17def test_swagger_ui(): 1abcd

18 response = client.get("/docs") 1efgh

19 assert response.status_code == 200, response.text 1efgh

20 print(response.text) 1efgh

21 assert "ui.initOAuth" in response.text 1efgh

22 assert '"appName": "The Predendapp"' in response.text 1efgh

23 assert '"clientId": "the-foo-clients"' in response.text 1efgh

24 

25 

26def test_response(): 1abcd

27 response = client.get("/items/") 1ijkl

28 assert response.json() == {"id": "foo"} 1ijkl