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
Checks
assert html.count("<svg") == 1, htmlassert "<details" in html and "2 more" in htmlassert 'href="flow-b.html#test=t"' in html and 'href="flow-c.html#test=t"' in htmlassert wider.count("<svg") == 2 and "1 more" in wider
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_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
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
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 htmlassert 'data-flow-play="callflow"' in html and 'data-slice-control="play"' not in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-025 | inferred | test_a_test_s_call_flow_plays_in_call_order_with_briefs → _callflow → symbol_href |
| REQ-DDB-WIKI-045 | measured | test_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 html1 more lines, not shown
Activity · 9 steps
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
Checks
assert 'data-slice-control="play"' in html and 'data-slice-control="step"' in htmlassert "data-flow-speed" in html and "_static/clew-views.js" in htmlassert "WPM = 238" in views and "g.st.ex" in views
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_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
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 == 1assert config.test_slices == 2 and problems == []assert any("wiki.test_slices" in p for p in problems), problems
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_wiki_test_slices_is_a_whole_number_of_one_or_more → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-054 | inferred | test_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