artenschutz-router/tests/test_app.py
m2 (AI Agent) 6da874b2e6 Initial commit — phase 1 + 2 of artenschutz-digest concept
Phase 1: router skeleton + Qdrant read path
- FastAPI app with /health, /search/generic, /ingest endpoints
- Qdrant reader (hybrid dense+sparse w/ RRF, plus payload scroll)
- BGE-M3 TEI client for query-side embedding
- memory-api client proxying writes to /memory/store (m2-memory untouched)
- Pydantic Fact + Exemplar payloads, discriminated by `kind`
- Dockerfile + docker-compose joining the coolify Docker network

Phase 2: authoritative-source ingest pipeline
- PDF text extraction + paragraph-aware (§ N) and size chunkers
- Loaders for bnatschg, mhbasp, biotopwertliste, state-<slug>
- CLI: artenschutz-ingest --source <name> [--states ...] [--dry-run]
- Helper script to fetch BNatSchG from gesetze-im-internet.de
- End-to-end smoke script (scripts/smoke.sh) for Coolify validation

22/22 unit tests pass. Real-world dry-runs verified against mhbasp Anhang 4,
biotopwertlisteNEU and Berlin Kartierstandards PDFs from GST-DATA.

See COOLIFY-DEPLOY.md for staging deploy + smoke procedure.
2026-05-14 16:36:00 +02:00

30 lines
1.1 KiB
Python

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"]