test_wiki_reqwhat.py¶
tests/test_wiki_reqwhat.py
A requirement page shows WHAT is required as plainly as HOW it is met (W-9, 2.0.0).
test_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did
None test_wiki_reqwhat.test_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did()
Summary first, passing folded.
Checks
assert "3 tests: 1 failed, 2 passed" in headassert "test_bad" in visible and "test_ok1" not in visibleassert "2 passed" in folded and "test_ok1" in folded and "test_ok2" in folded
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-012 | inferred | test_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did → _tests → table |
| REQ-DDB-WIKI-022 | measured | |
| REQ-DDB-WIKI-026 | measured | test_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did → _tests → test_link |
Source · 27 lines
def test_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did() -> None:
"""UX review D-7 (owner Q/A 2026-11-22): "Tests (376) is one flat table where most rows say the
same thing". Each table opens on its summary; tests that did not pass stay visible; passing ones
fold under their count. Nothing is cut (round 4): every test is still on the page.
@brief Summary first, passing folded.
"""
from clew.wiki.reqmodal import _tests
row = SimpleNamespace(
tests=(("test_ok1", "passed"), ("test_ok2", "passed"), ("test_bad", "failed")),
inferred_tests=(),
measured_tests=(),
declared_tests=(),
extent=(),
distance=(),
implementers=("f",),
req_id="REQ-A-001",
)
html = _tests(row, {})
head = html.split("<table", 1)[0]
assert "3 tests: 1 failed, 2 passed" in head
visible, folded = html.split("<details", 1)
assert "test_bad" in visible and "test_ok1" not in visible
assert "2 passed" in folded and "test_ok1" in folded and "test_ok2" in folded
Activity · 8 steps
test_many_requirement_pills_fold_and_each_links_its_page
None test_wiki_reqwhat.test_many_requirement_pills_fold_and_each_links_its_page()
Pills: few inline, many folded, page links.
tests/test_wiki_reqwhat.py:104
Checks
assert ('<a class="req-badge" href="req-REQ-A-001.html">REQ-A-001</a>' in few and "<details" not in few )assert many.startswith('<details class="fold"><summary>5 requirements</summary>')
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-022 | measured | test_many_requirement_pills_fold_and_each_links_its_page → _badges → page_of |
Source · 15 lines
def test_many_requirement_pills_fold_and_each_links_its_page() -> None:
"""UX review D-10: walls of REQ pills. Three or fewer inline; more fold under "N requirements";
each pill opens the requirement's own page, not an anchor on the index.
@brief Pills: few inline, many folded, page links.
"""
from clew.wiki.flowpage import _badges
few = _badges(["REQ-A-002", "REQ-A-001"])
assert (
'<a class="req-badge" href="req-REQ-A-001.html">REQ-A-001</a>' in few
and "<details" not in few
)
many = _badges([f"REQ-A-00{i}" for i in range(1, 6)])
assert many.startswith('<details class="fold"><summary>5 requirements</summary>')1 more lines, not shown
Activity · 5 steps
test_the_what_section_lists_criteria_facts_scenario_and_where
None test_wiki_reqwhat.test_the_what_section_lists_criteria_facts_scenario_and_where()
Criteria split one per line; facts; the declared scenario; blocks by implementer count.
Checks
assert "<h2>What it requires</h2>" in htmlassert ("<li>Options resolve through one rule.</li><li>The winning tier is recorded.</li>" in html )assert "verification" in html and "test" in htmlassert '<b class="kw">Given</b> a flag and a declaration' in htmlassert html.index("Config") < html.index("Server"), "blocks ordered by implementer count"assert 'href="map.html#req=REQ-A-001"' in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-022 | measured | test_the_what_section_lists_criteria_facts_scenario_and_where → _what |
Source · 21 lines
def test_the_what_section_lists_criteria_facts_scenario_and_where() -> None:
"""@brief Criteria split one per line; facts; the declared scenario; blocks by implementer count."""
from clew.wiki.reqmodal import _what
entry = {
"acceptance": "Options resolve through one rule. The winning tier is recorded.",
"verification": "test",
"scenario": "Given a flag and a declaration\nWhen a build resolves options\nThen the flag wins",
}
ctx = {"rules": Audience(), "blocks": {"src/tiers.py": "Config", "src/state.py": "Server"}}
html = _what(_row(), entry, ctx)
assert "<h2>What it requires</h2>" in html
assert (
"<li>Options resolve through one rule.</li><li>The winning tier is recorded.</li>" in html
)
assert "verification" in html and "test" in html
assert '<b class="kw">Given</b> a flag and a declaration' in html
assert html.index("Config") < html.index("Server"), "blocks ordered by implementer count"
assert 'href="map.html#req=REQ-A-001"' in html
Activity · 10 steps
test_withheld_requirement_text_is_not_shown
None test_wiki_reqwhat.test_withheld_requirement_text_is_not_shown()
An audience that withholds requirement text gets no criteria or scenario.
Checks
assert "Secret." not in html and "kw" not in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-022 | measured | test_withheld_requirement_text_is_not_shown → _what |
Source · 9 lines
def test_withheld_requirement_text_is_not_shown() -> None:
"""@brief An audience that withholds requirement text gets no criteria or scenario."""
from clew.wiki.reqmodal import _what
entry = {"acceptance": "Secret.", "scenario": "Given x\nWhen y\nThen z"}
html = _what(_row(), entry, {"rules": Audience(exclude_requirement_text=True), "blocks": {}})
assert "Secret." not in html and "kw" not in html