Testing
The test suite separates reproducible offline checks from tests that require locally obtained official DICOM artifacts or network access.
Offline gates
Section titled “Offline gates”Run before every change is considered complete:
make lintmake typecheckmake testThese map to:
uv run --dev ruff check .uv run --dev mypyuv run --dev pytestThe default suite uses synthetic and small attributed fixtures. It must not require an official DICOM download.
Focused tests
Section titled “Focused tests”uv run --dev pytest tests/unit/test_query_resolver.pyuv run --dev pytest tests/unit/test_mcp_server.pyuv run --dev pytest tests/agent_regressionUse the most focused test while iterating, then run the full offline gates.
Test groups
Section titled “Test groups”tests/unit/tests/agent_regression/tests/fixtures_synthetic/tests/fixtures_minimal_attributed/tests/integration_requires_dicom_download/Unit tests
Section titled “Unit tests”Cover source discovery, manifest integrity, parsing, migrations, imports, repositories, resolvers, CLI behavior, MCP registration/protocol behavior, configuration, JSON schemas, distribution audit, and related utilities.
Agent regression
Section titled “Agent regression”Committed prompt cases define expected deterministic tool traces before answer synthesis. The suite checks routing and evidence preservation rather than making free-form model text authoritative.
Synthetic fixtures
Section titled “Synthetic fixtures”Project-authored DocBook structures exercise parser branches offline.
Minimal attributed fixtures
Section titled “Minimal attributed fixtures”Tiny attributed excerpts are used only when synthetic material cannot faithfully reproduce the behavior under test.
Official-artifact integration
Section titled “Official-artifact integration”Tests under integration_requires_dicom_download use a local official cache or
explicit network enablement. They are separate so ordinary contributors do not
need to redistribute or automatically download the standard.
Integration commands
Section titled “Integration commands”Run smoke integration against an available local official cache:
make test-dicom-integrationThe underlying target is:
uv run --dev pytest tests/integration_requires_dicom_downloadRun current-release discovery only when network access is intentionally enabled:
make test-dicom-currentThis sets:
DICOM_KB_RUN_CURRENT=1Run the strict official-edition release gate:
make test-dicom-releaseThis sets:
DICOM_KB_RUN_RELEASE=1The release gate must fail rather than quietly skip when the required full part set or semantic rows are absent.
Build smoke test
Section titled “Build smoke test”After parser or migration changes:
uv run --dev dicom-kb build-fixture \ --edition 2026b \ --db /tmp/dicom-kb-test.sqlite \ --force
uv run --dev dicom-kb verify \ --edition 2026b \ --db /tmp/dicom-kb-test.sqliteRun representative CLI and Python queries against the result.
What to assert
Section titled “What to assert”For public query changes, assert:
- status and result fields;
- references;
- warnings;
- classification;
- parse confidence;
- trace shape;
- CLI JSON;
- MCP schema, dispatch, and protocol output;
- Python Pydantic output;
- ambiguous and not-found behavior;
- malformed input behavior.
For parser changes, assert:
- source references;
- ordering;
- include and cross-reference behavior;
- parser warnings;
- import counts;
- build metrics;
- quality-gate behavior;
- no forbidden distribution artifact is introduced.
Record skipped prerequisites
Section titled “Record skipped prerequisites”When official-edition or current-release tests cannot run, record the missing local prerequisite in release notes or review output. Do not describe a skipped gate as passed.