Skip to content

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

1
2
3
4
tests/
    integration/     # TestClient(app) + mocked resources
    unit/            # models, converters, pipeline stages/roots
    conftest.py      # fixtures

🚀 Integration tests

  • Build the app with TestClient.
  • Replace app.state.db_resources with 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.
1
2
3
4
5
6
client = TestClient(app)
app.state.db_resources = {"item_svc": FakeItemService(), ...}

def test_create_item():
    r = client.post("/items", json={"name": "x"})
    assert r.status_code == 200

🧪 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.
  • pytest passes.
  • 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.