| 1 |
import importlib |
| 2 |
|
| 3 |
import pytest |
| 4 |
from fastapi.testclient import TestClient |
| 5 |
from pytest import MonkeyPatch |
| 6 |
|
| 7 |
|
| 8 |
@pytest.fixture(name="app", params=[pytest.param("tutorial001_py310")]) |
| 9 |
def get_app(request: pytest.FixtureRequest, monkeypatch: MonkeyPatch): |
| 10 |
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]") |
| 11 |
mod = importlib.import_module(f"docs_src.settings.{request.param}") |
| 12 |
return mod.app |
| 13 |
|
| 14 |
|
| 15 |
def test_settings(app): |
| 16 |
client = TestClient(app) |
| 17 |
response = client.get("/info") |
| 18 |
assert response.status_code == 200, response.text |
| 19 |
assert response.json() == { |
| 20 |
"app_name": "Awesome API", |
| 21 |
"admin_email": "[email protected]", |
| 22 |
"items_per_user": 50, |
| 23 |
} |