Appearance
Backend tests (contract tests, seams, hypothesis, gates)
Applies to: **/tests/**/*.py
Checklist
- Tests drive production entry points:
TestClientaroundcreate_appwith injected fakes; flag hand-built routers, framework internals asserted directly (route registries, OpenAPI), and live network/model calls. - Mock at the seam the code already owns (monkeypatch adapter methods like
DelegationVercelAIAdapter.dispatch_requestwithAsyncMock); flag patching internals behind seams. - Hypothesis is required for behaviours touching untrusted input (id patterns, chat parsing, streaming chunk mapping, boundary mapping); one hard-coded case is not a substitute.
- Assert resulting behaviour and response shape, not mock call bookkeeping.
- Gates:
uv run ty check .,uv run ruff check .,uv run pytest— same commands as CI, run from the repo root. - Keep tests at
backend/tests/contract/...mirroring behaviour names; flagskip = Truewithout a reason comment.