Coverage for tests/test_tutorial/test_custom_response/test_tutorial006c.py: 100%

11 statements  

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

1from fastapi.testclient import TestClient 1abcdefg

2 

3from docs_src.custom_response.tutorial006c import app 1abcdefg

4 

5client = TestClient(app) 1abcdefg

6 

7 

8def test_redirect_status_code(): 1abcdefg

9 response = client.get("/pydantic", follow_redirects=False) 1hijklmn

10 assert response.status_code == 302 1hijklmn

11 assert response.headers["location"] == "https://docs.pydantic.dev/" 1hijklmn

12 

13 

14def test_openapi_schema(): 1abcdefg

15 response = client.get("/openapi.json") 1opqrstu

16 assert response.status_code == 200, response.text 1opqrstu

17 assert response.json() == { 1opqrstu

18 "openapi": "3.1.0", 

19 "info": {"title": "FastAPI", "version": "0.1.0"}, 

20 "paths": { 

21 "/pydantic": { 

22 "get": { 

23 "summary": "Redirect Pydantic", 

24 "operationId": "redirect_pydantic_pydantic_get", 

25 "responses": {"302": {"description": "Successful Response"}}, 

26 } 

27 } 

28 }, 

29 }