Coverage for tests/test_swagger_ui_init_oauth.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from fastapi import FastAPI 1abcdefg

2from fastapi.testclient import TestClient 1abcdefg

3 

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

5 

6app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth) 1abcdefg

7 

8 

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

10async def read_items(): 1abcdefg

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

12 

13 

14client = TestClient(app) 1abcdefg

15 

16 

17def test_swagger_ui(): 1abcdefg

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

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

20 print(response.text) 1hijklmn

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

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

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

24 

25 

26def test_response(): 1abcdefg

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

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