test_wiki_activity.py¶
tests/test_wiki_activity.py
A function's activity diagram, from its parsed body (round 5, P5.5; owner Q/A 2026-11-20).
test_a_call_flow_box_links_to_the_activity_with_the_lines_this_test_ran
None test_wiki_activity.test_a_call_flow_box_links_to_the_activity_with_the_lines_this_test_ran()
The call-flow boxes.
tests/test_wiki_activity.py:100
Checks
assert 'href="sym-pkg-store-py.html?lit=4-6,9#act-s-save"' in htmlassert ">helper</span>" in html and 'href="sym-pkg-h-py' not in htmlassert "<code>test_save</code>" in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-025 | measured | test_a_call_flow_box_links_to_the_activity_with_the_lines_this_test_ran → _callflow → symbol_href |
| REQ-DDB-WIKI-045 | measured | test_a_call_flow_box_links_to_the_activity_with_the_lines_this_test_ran → _callflow |
Source · 20 lines
def test_a_call_flow_box_links_to_the_activity_with_the_lines_this_test_ran() -> None:
"""OWNER (round 5, P5.5): clicking a box opens that function's activity diagram, lit with the
lines THIS test executed. The box links the function's page at its activity block with
`?lit=`; a function without a written page gets a box with no link, never a broken one.
@brief The call-flow boxes.
"""
from clew.wiki.testpages import _callflow
html = _callflow(
"test_save",
[("save", "pkg/store.py"), ("helper", "pkg/h.py")],
{"pkg/store.py": {4, 5, 6, 9}},
{("save", "pkg/store.py")},
)
assert 'href="sym-pkg-store-py.html?lit=4-6,9#act-s-save"' in html
assert ">helper</span>" in html and 'href="sym-pkg-h-py' not in html
assert "<code>test_save</code>" in html
Activity · 5 steps
test_an_elif_is_a_condition_at_the_same_depth
None test_wiki_activity.test_an_elif_is_a_condition_at_the_same_depth()
`elif` is not `else` + nested `if`; a final `else` keeps its own line.
tests/test_wiki_activity.py:77
Checks
assert [(s.kind, s.text, s.first, s.depth) for s in steps] == [
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | measured | test_an_elif_is_a_condition_at_the_same_depth → steps_of |
Source · 16 lines
def test_an_elif_is_a_condition_at_the_same_depth() -> None:
"""@brief `elif` is not `else` + nested `if`; a final `else` keeps its own line."""
src = (
"def f(x):\n if x > 1:\n a()\n elif x:\n b()\n else:\n c()\n"
)
steps = steps_of(src.splitlines(), "m.py", 1)
assert [(s.kind, s.text, s.first, s.depth) for s in steps] == [
(COND, "if x > 1", 2, 0),
(STMT, "a()", 3, 1),
(COND, "elif x", 4, 0),
(STMT, "b()", 5, 1),
(ELSE, "else", 6, 0),
(STMT, "c()", 7, 1),
]
Activity · 3 steps
test_an_unknown_language_has_no_diagram
None test_wiki_activity.test_an_unknown_language_has_no_diagram()
No parser: no steps, no SVG.
tests/test_wiki_activity.py:72
Checks
assert steps_of(["fn x() {}"], "src/m.rs", 1) == [] and activity_svg([], "x") == ""
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | measured | test_an_unknown_language_has_no_diagram → steps_of |
Source · 5 lines
def test_an_unknown_language_has_no_diagram() -> None:
"""@brief No parser: no steps, no SVG."""
assert steps_of(["fn x() {}"], "src/m.rs", 1) == [] and activity_svg([], "x") == ""
Activity · 1 steps
test_cpp_steps_follow_the_same_shape
None test_wiki_activity.test_cpp_steps_follow_the_same_shape()
tree-sitter: the same seven steps for the C++ twin.
tests/test_wiki_activity.py:57
Checks
assert [(s.kind, s.depth) for s in steps] == _EXPECTEDassert steps[2].text == "if (i % 2)" and steps[-1].text == "return out;"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | measured | test_cpp_steps_follow_the_same_shape → steps_of |
Source · 7 lines
def test_cpp_steps_follow_the_same_shape() -> None:
"""@brief tree-sitter: the same seven steps for the C++ twin."""
steps = steps_of(_CPP.splitlines(), "src/m.cpp", first_line=1)
assert [(s.kind, s.depth) for s in steps] == _EXPECTED
assert steps[2].text == "if (i % 2)" and steps[-1].text == "return out;"
Activity · 3 steps
test_line_ranges_are_compact_and_ordered
None test_wiki_activity.test_line_ranges_are_compact_and_ordered()
`{20, 12, 13, 14, 15}` → `12-15,20`: what a box's link carries.
tests/test_wiki_activity.py:93
Checks
assert _ranges({20, 12, 13, 14, 15}) == "12-15,20" and _ranges(set()) == ""
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | catalog |
Source · 7 lines
def test_line_ranges_are_compact_and_ordered() -> None:
"""@brief `{20, 12, 13, 14, 15}` → `12-15,20`: what a box's link carries."""
from clew.wiki.testpages import _ranges
assert _ranges({20, 12, 13, 14, 15}) == "12-15,20" and _ranges(set()) == ""
Activity · 2 steps
test_python_steps_follow_the_control_flow_with_absolute_lines
None test_wiki_activity.test_python_steps_follow_the_control_flow_with_absolute_lines()
`ast`: the docstring is not a step; lines are the file's (the body starts at 20).
tests/test_wiki_activity.py:49
Checks
assert [(s.kind, s.depth) for s in steps] == _EXPECTEDassert [s.first for s in steps] == [22, 23, 24, 25, 26, 27, 28]assert steps[1].text == "for item in items" and steps[-1].text == "return out"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | measured | test_python_steps_follow_the_control_flow_with_absolute_lines → steps_of |
Source · 8 lines
def test_python_steps_follow_the_control_flow_with_absolute_lines() -> None:
"""@brief `ast`: the docstring is not a step; lines are the file's (the body starts at 20)."""
steps = steps_of(_PY.splitlines(), "src/m.py", first_line=20)
assert [(s.kind, s.depth) for s in steps] == _EXPECTED
assert [s.first for s in steps] == [22, 23, 24, 25, 26, 27, 28]
assert steps[1].text == "for item in items" and steps[-1].text == "return out"
Activity · 4 steps
test_the_page_script_lights_the_linked_lines
None test_wiki_activity.test_the_page_script_lights_the_linked_lines()
clew.js reads `lit` and marks the activity steps it covers.
tests/test_wiki_activity.py:120
Checks
assert "lit" in js and ".activity" in js
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | catalog |
Source · 6 lines
def test_the_page_script_lights_the_linked_lines() -> None:
"""@brief clew.js reads `lit` and marks the activity steps it covers."""
from clew.wiki.theme import THEMES
js = (THEMES / "clew" / "static" / "clew.js").read_text()
assert "lit" in js and ".activity" in js1 more lines, not shown
Activity · 3 steps
test_the_svg_carries_each_steps_lines_for_lighting
None test_wiki_activity.test_the_svg_carries_each_steps_lines_for_lighting()
`data-l` per step, a loop back edge, an accessible label, no script.
tests/test_wiki_activity.py:64
Checks
assert svg.count('class="step ') == 7 and 'data-l="25-25"' in svgassert 'class="loop-back"' in svg and 'aria-label="activity of load: 7 steps"' in svgassert "<script" not in svg
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-045 | measured | test_the_svg_carries_each_steps_lines_for_lighting → steps_of |
Source · 8 lines
def test_the_svg_carries_each_steps_lines_for_lighting() -> None:
"""@brief `data-l` per step, a loop back edge, an accessible label, no script."""
svg = activity_svg(steps_of(_PY.splitlines(), "src/m.py", 20), "load")
assert svg.count('class="step ') == 7 and 'data-l="25-25"' in svg
assert 'class="loop-back"' in svg and 'aria-label="activity of load: 7 steps"' in svg
assert "<script" not in svg