test_wiki_viewer.py¶
tests/test_wiki_viewer.py
Viewer caps that expand without bloating the page (V1–V6; owner Q/A 2026-11-20).
test_body_lines_is_a_setting_and_a_cut_body_links_its_source
None test_wiki_viewer.test_body_lines_is_a_setting_and_a_cut_body_links_its_source(tmp_path)
V6: `wiki.body_lines` (default 120); past it, "N more lines" links the full source.
Checks
assert config.body_lines == 3 and problems == []assert "8 more lines" in html and 'href="https://example.invalid/m.py#L1"' in html
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_body_lines_is_a_setting_and_a_cut_body_links_its_source → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-054 | inferred | test_body_lines_is_a_setting_and_a_cut_body_links_its_source → load_wiki_config → _comments → all |
Source · 13 lines
def test_body_lines_is_a_setting_and_a_cut_body_links_its_source(tmp_path) -> None:
"""@brief V6: `wiki.body_lines` (default 120); past it, "N more lines" links the full source."""
from clew.wiki.config import load_wiki_config
from clew.wiki.symbols import Definition, _body
(tmp_path / ".clew.yaml").write_text("wiki:\n body_lines: 3\n")
config, problems = load_wiki_config(tmp_path, None)
assert config.body_lines == 3 and problems == []
(tmp_path / "m.py").write_text("def f():\n" + "".join(f" x{i} = {i}\n" for i in range(10)))
d = Definition(1, "f", "m.py", "def f()", "", 1, 11)
ctx = {"body_lines": 3, "template": "https://example.invalid/{file}#L{line}", "commit": "c0"}
html = _body(tmp_path, d, ctx)
assert "8 more lines" in html and 'href="https://example.invalid/m.py#L1"' in html1 more lines, not shown
Activity · 10 steps
test_flows_past_the_cap_open_in_a_details
None test_wiki_viewer.test_flows_past_the_cap_open_in_a_details()
V5: 7 flows on a changed function's row — 5 shown, 2 behind "2 more", all linked.
Checks
assert "<summary>2 more</summary>" in htmlassert all(f'href="flow-{i}.html"' in html for i in range(7))
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | measured | test_flows_past_the_cap_open_in_a_details → _flow_cell |
| REQ-DDB-WIKI-054 | inferred | test_flows_past_the_cap_open_in_a_details → all |
Source · 10 lines
def test_flows_past_the_cap_open_in_a_details() -> None:
"""@brief V5: 7 flows on a changed function's row — 5 shown, 2 behind "2 more", all linked."""
from clew.wiki.impactpage import _flow_cell
pages = [SimpleNamespace(name=f"flow-{i}", title=f"Flow {i}", role="product") for i in range(7)]
html = _flow_cell(pages)
assert "<summary>2 more</summary>" in html
assert all(f'href="flow-{i}.html"' in html for i in range(7))
Activity · 5 steps
test_neighbours_past_the_cap_open_in_a_details
None test_wiki_viewer.test_neighbours_past_the_cap_open_in_a_details()
V3: 15 callers — 12 inline, 3 behind "3 more", every name present.
Checks
assert "<summary>3 more</summary>" in htmlassert all(f">f{i}<" in html for i in range(15))
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-025 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_neighbours_past_the_cap_open_in_a_details → all |
Source · 10 lines
def test_neighbours_past_the_cap_open_in_a_details() -> None:
"""@brief V3: 15 callers — 12 inline, 3 behind "3 more", every name present."""
from clew.wiki.symbols import _names
pairs = [(f"f{i}", "a.py") for i in range(15)]
html = _names(pairs, {("f0", "a.py")})
assert "<summary>3 more</summary>" in html
assert all(f">f{i}<" in html for i in range(15))