Coverage for tests/test_swagger_ui_init_oauth.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-01-13 13:38 +0000

1from fastapi import FastAPI 1abcde

2from fastapi.testclient import TestClient 1abcde

3 

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

5 

6app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth) 1abcde

7 

8 

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

10async def read_items(): 1abcde

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

12 

13 

14client = TestClient(app) 1abcde

15 

16 

17def test_swagger_ui(): 1abcde

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

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

20 print(response.text) 1fghij

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

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

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

24 

25 

26def test_response(): 1abcde

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

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