from __future__ import annotations from fastapi.testclient import TestClient from artenschutz_router.main import app def test_app_constructs(): """Smoke test: app object exists, routes registered.""" paths = {route.path for route in app.routes} assert "/health" in paths assert "/search/generic" in paths assert "/ingest" in paths def test_openapi_schema_renders(): # Force lifespan to skip (we don't have Qdrant/BGE running in unit tests). # We can still call openapi.json which doesn't touch the lifespan-managed # clients. with TestClient(app, raise_server_exceptions=False) as client: # Disable lifespan by short-circuiting via app.state — not strictly # necessary for openapi but keeps the test fast. resp = client.get("/openapi.json") # If lifespan failed connecting to deps, app may still serve openapi. assert resp.status_code == 200 spec = resp.json() assert spec["info"]["title"] == "artenschutz-router" assert "/search/generic" in spec["paths"] assert "/ingest" in spec["paths"] assert "/health" in spec["paths"]