Coverage for tests/test_tutorial/test_advanced_middleware/test_tutorial001.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi.testclient import TestClient 1abcde

2 

3from docs_src.advanced_middleware.tutorial001 import app 1abcde

4 

5 

6def test_middleware(): 1abcde

7 client = TestClient(app, base_url="https://testserver") 1abcde

8 response = client.get("/") 1abcde

9 assert response.status_code == 200, response.text 1abcde

10 

11 client = TestClient(app) 1abcde

12 response = client.get("/", follow_redirects=False) 1abcde

13 assert response.status_code == 307, response.text 1abcde

14 assert response.headers["location"] == "https://testserver/" 1abcde