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.

tests/test_wiki_reqwhat.py:64

Show on the map →

Called by none

Calls _tests

Checks

  • assert "3 tests: 1 failed, 2 passed" in head
  • 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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-012inferredtest_a_requirement_s_tests_show_what_did_not_pass_and_fold_what_did → _tests → table
REQ-DDB-WIKI-022measured
REQ-DDB-WIKI-026measuredtest_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
lines 71–71from clew.wiki.reqmodal import _testslines 73–82row = 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", )lines 83–83html = _tests(row, {})lines 84–84head = html.split("<table", 1)[0]lines 85–85assert "3 tests: 1 failed, 2 passed" in headlines 86–86visible, folded = html.split("<details", 1)lines 87–87assert "test_bad" in visible and "test_ok1" not in visiblelines 88–88assert "2 passed" in folded and "test_ok1" in folded and "test_ok2" in folded

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.

tests/test_wiki_reqwhat.py:34

Show on the map →

Called by none

Calls _row, _what

Checks

  • 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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-022measuredtest_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
lines 36–36from clew.wiki.reqmodal import _whatlines 38–42entry = { "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", }lines 43–43ctx = {"rules": Audience(), "blocks": {"src/tiers.py": "Config", "src/state.py": "Server"}}lines 44–44html = _what(_row(), entry, ctx)lines 45–45assert "<h2>What it requires</h2>" in htmllines 46–48assert ( "<li>Options resolve through one rule.</li><li>The winning tier is recorded.</li>" in html )lines 49–49assert "verification" in html and "test" in htmllines 50–50assert '<b class="kw">Given</b> a flag and a declaration' in htmllines 51–51assert html.index("Config") < html.index("Server"), "blocks ordered by implementer count"lines 52–52assert 'href="map.html#req=REQ-A-001"' in html

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.

tests/test_wiki_reqwhat.py:55

Show on the map →

Called by none

Calls _row, _what

Checks

  • assert "Secret." not in html and "kw" not in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-022measuredtest_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

Activity · 4 steps
lines 57–57from clew.wiki.reqmodal import _whatlines 59–59entry = {"acceptance": "Secret.", "scenario": "Given x\nWhen y\nThen z"}lines 60–60html = _what(_row(), entry, {"rules": Audience(exclude_requirement_text=True), "blocks": {}})lines 61–61assert "Secret." not in html and "kw" not in html