e047d884b6
Backend (uv): FastAPI app with routers (foods, log, targets, OFF proxy), SQLAlchemy models, Pydantic schemas, migration runner + 0001 initial schema, example pytest suite (7 tests). Frontend (npm): Vite 7 + Svelte 5 runes, lib/ (api, stores, scanner, format) per spec §7, placeholder components, example vitest suite (4 tests). SPEC.md §1: registered uvicorn and Vitest (rule §8.3.3).
23 lines
580 B
Python
23 lines
580 B
Python
"""Test fixtures: fresh temp-file SQLite DB per test session (spec §8.4)."""
|
|
|
|
import os
|
|
import tempfile
|
|
|
|
import pytest
|
|
|
|
# Must be set before any app module is imported (engine binds at import time)
|
|
_tmpdir = tempfile.mkdtemp(prefix="calcount-test-")
|
|
os.environ["CALCOUNT_DATABASE_URL"] = f"sqlite:///{_tmpdir}/test.db"
|
|
|
|
from fastapi.testclient import TestClient # noqa: E402
|
|
|
|
from database import run_migrations # noqa: E402
|
|
from main import app # noqa: E402
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def client():
|
|
run_migrations()
|
|
with TestClient(app) as c:
|
|
yield c
|