Files
siftlode/backend/tests/test_smoke.py
T
peter b1832afd18 style: apply ruff format across backend + scripts (line-length 100)
Mechanical, whole-tree `ruff format` pass — no behaviour change. Recorded in
.git-blame-ignore-revs (next commit) so git blame skips it.
2026-08-23 07:43:06 +02:00

28 lines
1.3 KiB
Python

"""App-assembly smoke test — DB-free.
Uses TestClient WITHOUT its context-manager form on purpose: that skips the lifespan (which opens a
DB session + starts the scheduler), so the app object can be built and its OpenAPI schema generated
with no database. That alone proves every included router imported and wired cleanly — a broken
route registration or import fails right here.
Endpoints that actually answer (/healthz, /api/version, the auth/feed/downloads routers) all touch
the database, so exercising THEM belongs in a DB-backed integration lane (needs a test Postgres +
migrations) — deferred; see siftlode-ops/ROADMAP.md R2 S2b.
"""
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app) # no `with` → lifespan/startup does not run → no DB required
def test_app_assembles_and_serves_openapi():
schema = client.get("/openapi.json")
assert schema.status_code == 200
paths = schema.json()["paths"]
# A handful of endpoints that must always exist — a rename/removal is a real contract change,
# and their absence here would mean a router failed to register.
for path in ["/healthz", "/api/version", "/api/feed", "/api/me"]:
assert path in paths, f"missing route {path} — a router failed to wire up"