- GET /api/health prüft die Datenbankverbindung - SQLite im WAL-Modus unter /data/app.db - Auslieferung des gebauten Frontends mit SPA-Fallback - leere Basis-Migration, Tests mit pytest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
875 B
Python
37 lines
875 B
Python
from collections.abc import Iterator
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.config import get_settings
|
|
from app.db import _session_factory, get_engine
|
|
|
|
|
|
def _clear_caches() -> None:
|
|
get_settings.cache_clear()
|
|
get_engine.cache_clear()
|
|
_session_factory.cache_clear()
|
|
|
|
|
|
@pytest.fixture
|
|
def static_dir(tmp_path):
|
|
"""Directory for the built frontend; empty by default (no SPA routes)."""
|
|
path = tmp_path / "static"
|
|
path.mkdir()
|
|
return path
|
|
|
|
|
|
@pytest.fixture
|
|
def client(tmp_path, static_dir, monkeypatch) -> Iterator[TestClient]:
|
|
monkeypatch.setenv("DATA_DIR", str(tmp_path / "data"))
|
|
monkeypatch.setenv("STATIC_DIR", str(static_dir))
|
|
_clear_caches()
|
|
|
|
from app.main import create_app
|
|
|
|
with TestClient(create_app()) as test_client:
|
|
yield test_client
|
|
|
|
get_engine().dispose()
|
|
_clear_caches()
|