docs(standards): mirror doc-forge wiki style; mermaid + copyable build prompt
- move templates into src/templates; renumber wiki pages; add app-components page - embed agentic build prompt as a copyable markdown block; add mermaid diagrams - build.py writes <name>/mcp; config static bundle -> standards/mcp - registry reads libraries.json as bytes (committed file was UTF-16LE); normalize to UTF-8 - Dockerfile: drop stale blog copy; per-repo <name>/mcp copies - drop nested standards/mcp/standards duplicate and empty root mcp/
This commit is contained in:
81
standards/src/wiki/04_development/01_testing.md
Normal file
81
standards/src/wiki/04_development/01_testing.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# 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
|
||||
|
||||
```
|
||||
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.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.
|
||||
|
||||
```python
|
||||
client = TestClient(app)
|
||||
app.state.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.
|
||||
|
||||
---
|
||||
|
||||
## Related
|
||||
|
||||
- [02 – App Components](02_components.md) · [03 – Build Recipe](03_build_recipe.md) · [Overview](../01_overview.md)
|
||||
Reference in New Issue
Block a user