Coverage for tests/test_tutorial/test_settings/test_tutorial001_pv1.py: 100%

11 statements  

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

1from fastapi.testclient import TestClient 1abcde

2from pytest import MonkeyPatch 1abcde

3 

4from ...utils import needs_pydanticv1 1abcde

5 

6 

7@needs_pydanticv1 1abcde

8def test_settings(monkeypatch: MonkeyPatch): 1abcde

9 monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") 1abcde

10 from docs_src.settings.tutorial001_pv1 import app 1abcde

11 

12 client = TestClient(app) 1abcde

13 response = client.get("/info") 1abcde

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

15 assert response.json() == { 1abcde

16 "app_name": "Awesome API", 

17 "admin_email": "admin@example.com", 

18 "items_per_user": 50, 

19 }