test_wiki_testslices.py

tests/test_wiki_testslices.py

Tests drawn as slices of master flows, on a built site (round 5, R5-4c).

test_a_test_page_draws_its_top_slices_and_lists_the_rest

None test_wiki_testslices.test_a_test_page_draws_its_top_slices_and_lists_the_rest(monkeypatch)

Slices past the cap are links in a details list.

tests/test_wiki_testslices.py:167

Show on the map →

Called by none

Calls _exercises

Checks

  • assert html.count("<svg") == 1, html
  • assert "<details" in html and "2 more" in html
  • assert 'href="flow-b.html#test=t"' in html and 'href="flow-c.html#test=t"' in html
  • assert wider.count("<svg") == 2 and "1 more" in wider

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_a_test_page_draws_its_top_slices_and_lists_the_rest → _exercises
Source · 26 lines
def test_a_test_page_draws_its_top_slices_and_lists_the_rest(monkeypatch) -> None:
    """OWNER Q/A 2026-11-20 (after P6): slice diagrams were 84 MB of clew's 179 MB site — 8,148
    inline SVGs, three flows on most pages, by flow rank 49.2 / 21.6 / 13.3 MB. The top
    `wiki.test_slices` flows (default 1, by steps exercised) are drawn; the rest are a `<details>`
    "N more" list, each linking its whole flow lit for this test.

    @brief Slices past the cap are links in a details list.
    """
    from types import SimpleNamespace

    from clew.wiki import slices, testpages

    monkeypatch.setattr(slices, "slice_svg", lambda flow, cut: "<svg class='seq'/>")
    page = lambda n, s: SimpleNamespace(name=f"flow-{n}", title=n, steps=s, flow=None)  # noqa: E731
    cut = lambda k: SimpleNamespace(exercised=tuple(range(k)))  # noqa: E731
    cuts = [(page("a", 40), cut(9)), (page("b", 30), cut(5)), (page("c", 20), cut(2))]

    html = testpages._exercises("t", {"slices": {"t": cuts}})
    assert html.count("<svg") == 1, html
    assert "<details" in html and "2 more" in html
    assert 'href="flow-b.html#test=t"' in html and 'href="flow-c.html#test=t"' in html

    wider = testpages._exercises("t", {"slices": {"t": cuts}, "test_slices": 2})
    assert wider.count("<svg") == 2 and "1 more" in wider

Activity · 12 steps
lines 175–175from types import SimpleNamespacelines 177–177from clew.wiki import slices, testpageslines 179–179monkeypatch.setattr(slices, "slice_svg", lambda flow, cut: "<svg class='seq'/>")lines 180–180page = lambda n, s: SimpleNamespace(name=f"flow-{n}", title=n, steps=s, flow=None)lines 181–181cut = lambda k: SimpleNamespace(exercised=tuple(range(k)))lines 182–182cuts = [(page("a", 40), cut(9)), (page("b", 30), cut(5)), (page("c", 20), cut(2))]lines 184–184html = testpages._exercises("t", {"slices": {"t": cuts}})lines 185–185assert html.count("<svg") == 1, htmllines 186–186assert "<details" in html and "2 more" in htmllines 187–187assert 'href="flow-b.html#test=t"' in html and 'href="flow-c.html#test=t"' in htmllines 189–189wider = testpages._exercises("t", {"slices": {"t": cuts}, "test_slices": 2})lines 190–190assert wider.count("<svg") == 2 and "1 more" in wider

test_a_test_s_call_flow_plays_in_call_order_with_briefs

None test_wiki_testslices.test_a_test_s_call_flow_plays_in_call_order_with_briefs(tmp_path)

Call-flow boxes: call order, briefs, controls.

tests/test_wiki_testslices.py:228

Show on the map →

Called by none

Calls _callflow, _in_call_order

Checks

  • assert [n for n, _f in ordered] == ["save", "load", "check"]
  • assert 'data-brief="Write one record."' in html and 'title="Write one record."' in html
  • assert 'data-flow-play="callflow"' in html and 'data-slice-control="play"' not in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-025inferredtest_a_test_s_call_flow_plays_in_call_order_with_briefs → _callflow → symbol_href
REQ-DDB-WIKI-045measuredtest_a_test_s_call_flow_plays_in_call_order_with_briefs → _callflow
Source · 22 lines
def test_a_test_s_call_flow_plays_in_call_order_with_briefs(tmp_path) -> None:
    """X-3 (owner review 2, 2026-11-22): 1,322 of 2,775 test pages (48%) had no slice, so no player
    ("i still cant play a test back"). Every test page's call-flow boxes play: in the order the test
    CALLS them (they were sorted by name), each with its brief, at the slices' reading pace.

    @brief Call-flow boxes: call order, briefs, controls.
    """
    from types import SimpleNamespace

    from clew.wiki.testpages import _callflow, _in_call_order

    (tmp_path / "t.py").write_text(
        "def test_x():\n    b = save(1)\n    a = load()\n    check(a, b)\n"
    )
    d = SimpleNamespace(file="t.py", start=1, end=4)
    ordered = _in_call_order(tmp_path, d, [("check", "c.py"), ("load", "l.py"), ("save", "s.py")])
    assert [n for n, _f in ordered] == ["save", "load", "check"]
    html = _callflow("test_x", ordered, {}, set(), {("save", "s.py"): "Write one record."})
    assert 'data-brief="Write one record."' in html and 'title="Write one record."' in html
    ## SPEC CHANGED (UX review E-15, owner Q/A 2026-11-22): three boxes get no player — it appears
    ## past five (test_wiki_ux_small.test_a_short_call_flow_has_no_player).
    assert 'data-flow-play="callflow"' in html and 'data-slice-control="play"' not in html

1 more lines, not shown

Activity · 9 steps
lines 235–235from types import SimpleNamespacelines 237–237from clew.wiki.testpages import _callflow, _in_call_orderlines 239–241(tmp_path / "t.py").write_text( "def test_x():\n b = save(1)\n a = load()\n check(a, b)\n" )lines 242–242d = SimpleNamespace(file="t.py", start=1, end=4)lines 243–243ordered = _in_call_order(tmp_path, d, [("check", "c.py"), ("load", "l.py"), ("save", "s.py")])lines 244–244assert [n for n, _f in ordered] == ["save", "load", "check"]lines 245–245html = _callflow("test_x", ordered, {}, set(), {("save", "s.py"): "Write one record."})lines 246–246assert 'data-brief="Write one record."' in html and 'title="Write one record."' in htmllines 249–249assert 'data-flow-play="callflow"' in html and 'data-slice-control="play"' not in html

test_a_test_s_slices_are_playable

None test_wiki_testslices.test_a_test_s_slices_are_playable(monkeypatch)

Slices get play, step and speed.

tests/test_wiki_testslices.py:206

Show on the map →

Called by none

Calls _exercises

Checks

  • assert 'data-slice-control="play"' in html and 'data-slice-control="step"' in html
  • assert "data-flow-speed" in html and "_static/clew-views.js" in html
  • assert "WPM = 238" in views and "g.st.ex" in views

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_a_test_s_slices_are_playable → _exercises
Source · 22 lines
def test_a_test_s_slices_are_playable(monkeypatch) -> None:
    """W-6 (owner review 2026-11-22): "tests are not playable". The exercises section carries the
    player's controls and loads `clew-views.js`, whose slice player steps through the steps the test
    RAN (`g.st.ex`), in order, paced to reading speed like the flow player.

    @brief Slices get play, step and speed.
    """
    from pathlib import Path
    from types import SimpleNamespace

    import clew.wiki
    from clew.wiki import slices, testpages

    monkeypatch.setattr(slices, "slice_svg", lambda flow, cut: "<svg class='seq'/>")
    page = SimpleNamespace(name="flow-a", title="a", steps=4, flow=None)
    html = testpages._exercises("t", {"slices": {"t": [(page, SimpleNamespace(exercised=(1, 2)))]}})
    assert 'data-slice-control="play"' in html and 'data-slice-control="step"' in html
    assert "data-flow-speed" in html and "_static/clew-views.js" in html
    views = (Path(clew.wiki.__file__).parent / "themes/clew/static/clew-views.js").read_text()
    assert "WPM = 238" in views and "g.st.ex" in views

Activity · 11 steps
lines 213–213from pathlib import Pathlines 214–214from types import SimpleNamespacelines 216–216import clew.wikilines 217–217from clew.wiki import slices, testpageslines 219–219monkeypatch.setattr(slices, "slice_svg", lambda flow, cut: "<svg class='seq'/>")lines 220–220page = SimpleNamespace(name="flow-a", title="a", steps=4, flow=None)lines 221–221html = testpages._exercises("t", {"slices": {"t": [(page, SimpleNamespace(exercised=(1, 2)))]}})lines 222–222assert 'data-slice-control="play"' in html and 'data-slice-control="step"' in htmllines 223–223assert "data-flow-speed" in html and "_static/clew-views.js" in htmllines 224–224views = (Path(clew.wiki.__file__).parent / "themes/clew/static/clew-views.js").read_text()lines 225–225assert "WPM = 238" in views and "g.st.ex" in views

test_wiki_test_slices_is_a_whole_number_of_one_or_more

None test_wiki_testslices.test_wiki_test_slices_is_a_whole_number_of_one_or_more(tmp_path)

`wiki.test_slices` defaults to 1, reads a value, and refuses 0 by name.

tests/test_wiki_testslices.py:193

Checks

  • assert WikiConfig().test_slices == 1
  • assert config.test_slices == 2 and problems == []
  • assert any("wiki.test_slices" in p for p in problems), problems

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_wiki_test_slices_is_a_whole_number_of_one_or_more → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-054inferredtest_wiki_test_slices_is_a_whole_number_of_one_or_more → load_wiki_config → _comments → all
Source · 13 lines
def test_wiki_test_slices_is_a_whole_number_of_one_or_more(tmp_path) -> None:
    """@brief `wiki.test_slices` defaults to 1, reads a value, and refuses 0 by name."""
    from clew.wiki.config import WikiConfig, load_wiki_config

    assert WikiConfig().test_slices == 1
    (tmp_path / ".clew.yaml").write_text("wiki:\n  test_slices: 2\n")
    config, problems = load_wiki_config(tmp_path, None)
    assert config.test_slices == 2 and problems == []
    (tmp_path / ".clew.yaml").write_text("wiki:\n  test_slices: 0\n")
    _config, problems = load_wiki_config(tmp_path, None)
    assert any("wiki.test_slices" in p for p in problems), problems

Activity · 8 steps
lines 195–195from clew.wiki.config import WikiConfig, load_wiki_configlines 197–197assert WikiConfig().test_slices == 1lines 198–198(tmp_path / ".clew.yaml").write_text("wiki:\n test_slices: 2\n")lines 199–199config, problems = load_wiki_config(tmp_path, None)lines 200–200assert config.test_slices == 2 and problems == []lines 201–201(tmp_path / ".clew.yaml").write_text("wiki:\n test_slices: 0\n")lines 202–202_config, problems = load_wiki_config(tmp_path, None)lines 203–203assert any("wiki.test_slices" in p for p in problems), problems