Testing & Quality Gates
Two suites run under pytest with asyncio auto mode: integration (the HTTP edge against fakes) and unit (pure domain and pipeline logic). Finish a blueprint app only when every gate below passes.
🗂️ Layout
🚀 Integration tests
- Build the app with
TestClient. - Replace
app.state.db_resourceswith fake repositories/services so no database is required. - Patch the auth introspection call (
httpx.AsyncClient.post) to return a canned identity. - Assert status codes and bodies for list/get/create/update/delete, plus
400,404,204, and the streaming endpoint's fallback.
🧪 Unit tests
- Domain models and converters: pure, no I/O.
- Pipeline stages: feed a fixture state, assert the transformed state.
- Assembled pipeline roots: fixture parity — replay a stored fixture input and compare against a golden output file.
🔐 Config-consistency tests
For rule-driven pipelines, add a test that cross-references rules against the declared pattern registry: every flag emitted must be defined; every defined flag must be reachable. This catches drift without running the pipeline.
✅ Quality gates
A definition of done for any standard app:
python -c "import main"succeeds.pytestpasses.- The app serves the spec's operations; the worker drains its queue.
- No domain module imports a web framework.
- No infrastructure was reimplemented that a library already provides.
💡 Conventions
asyncio_mode = "auto"; no manual event loops.- Fixtures are checked into the repo (inputs + golden outputs).
- Tests skip (not fail) when a required fixture is absent.
- Do not mock the domain; mock only the infrastructure edge.