Matching engine E.6

Engine tests

The engine's tests live in tests/ and run offline: they use small synthetic fixtures, mock every download, and need no Flask, SQLAlchemy, database or national dataset. Run them from the engine repository root.

python -m pip install -e '.[swiss,gtfs,acquisition,test]'
python -m pytest tests -q

For the in-memory API and the matching rules only, install .[test] and run tests/test_api.py, tests/test_matching_regressions.py and tests/test_results.py; they import no adapter.

What the tests cover

Area Covered
Matching rules Reference, name, GTFS route and distance rules; rule order; source duplicate and OSM pair propagation, never to two-sided stop middles; namespace-safe references
Inputs Adapter parsing, valid zero coordinates, co-located elements, missing route evidence
Independence Separate runs share no state
Results The bundle writer and validator: corrupt bundles, incomplete outputs, atomic publication failure and concurrent writers
Properties Hypothesis cases in tests/test_quality_properties.py: identifier round trips through a bundle, conservation of matched and unmatched entities, maximum distance allocation and rejection of invalid coordinates
Architecture Import boundaries, public API imports and the catalog's ownership discovery, in tests/test_architecture.py
Progress The catalog and event lifecycle of tests/test_progress.py
Regression examples/swiss/expected.json: the expected matches, unmatched elements, groups, duplicates, problems and route matches of a small Swiss fixture

The progress tests check the contract, not durations or heartbeat counts, so adding a stage label never requires repeating matching assertions in an orchestration or browser test.

The engine's quality guide describes make quality, coverage and the optional mutation sample.

Reading bundles and publishing them as database snapshots is tested by the review application, with bundle contract tests and real PostGIS publication tests; see A4.1 Backend tests. The application also runs the engine's suite in its combined make quality and shows the code quality of both projects in its dashboard; A4.3 Code quality explains how to read it.