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

12 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.tutorial002 import app 1abcde

4 

5 

6def test_middleware(): 1abcde

7 client = TestClient(app, base_url="http://example.com") 1abcde

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

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

10 client = TestClient(app, base_url="http://subdomain.example.com") 1abcde

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

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

13 client = TestClient(app, base_url="http://invalidhost") 1abcde

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

15 assert response.status_code == 400, response.text 1abcde