test_each_function_carries_the_requirements_it_implements¶
Tests › tests/test_wiki_web.py
What this test is for
Why it exists
OWNER (round 5, P5.4): the requirement overlay. A requirement page's "Show on the map" opens `map.html#req=<id>`, which lights that requirement's implementing functions. The map data carries ONE table of ids and, per function, indices into it: a site of thousands of functions does not repeat each id string on every node it implements.
Given
rows = [ SimpleNamespace( req_id="R-2", tier="PASS", implementer_sites=(("save", "pkg/core/store.py", 4),) ), SimpleNamespace( req_id="R-1", tier="UNTESTED", implementer_sites=(("save", "pkg/core/store.py", 4), ("clean", "pkg/util.py", 1)), ), ]
When
data = web_data(db, build_graph(db, rows, None, _DECLARED, exclude_tests=True))by_name = {n["name"]: n.get("r") for n in data["nodes"]}
Then
- ✓ data["req_ids"] equals ["R-1", "R-2"]
- ✓ by_name["save"] equals [0, 1]
- ✓ by_name["clean"] equals [0]
- ✓ by_name["handle"] is None
- ✓ WEB_JS contains "req="
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
Build this wiki from the index · 20 of 400 steps
… 140 earlier steps
… 234 later steps
tests/test_wiki_web.py:172 · its file's page
What it checks (3)
assert data["req_ids"] == ["R-1", "R-2"]observesweb_dataviadataassert by_name["save"] == [0, 1] and by_name["clean"] == [0] and by_name["handle"] is Nonenot attributedassert "req=" in WEB_JS, "the map reads the overlay's hash"not attributed
Where the product reaches it
build_wiki→_build_site→build_graph(flow)
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 4 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-QUERY-001 measured
- REQ-DDB-QUERY-003 measured
- REQ-DDB-WIKI-019 measured
- REQ-DDB-WIKI-022 measured