test_wiki_exports.py¶
tests/test_wiki_exports.py
The site's exports (round 3, P3b): other tools' formats, generated from the same trace.
test_a_dot_identifier_is_quoted_and_escaped
None test_wiki_exports.test_a_dot_identifier_is_quoted_and_escaped()
A name with a quote or backslash cannot break the DOT file.
tests/test_wiki_exports.py:113
Checks
assert _dot_id('a"b\\c') == '"a\\"b\\\\c"'
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 5 lines
def test_a_dot_identifier_is_quoted_and_escaped() -> None:
"""@brief A name with a quote or backslash cannot break the DOT file."""
from clew.wiki.exports import _dot_id
assert _dot_id('a"b\\c') == '"a\\"b\\\\c"'1 more lines, not shown
Activity · 2 steps
test_exports_obey_the_audience
None test_wiki_exports.test_exports_obey_the_audience(tuple[Path, Path] repo, Path tmp_path)
`exclude_requirement_text` keeps titles and criteria out of every export.
Checks
assert "Load the data" not in text and "Every item is parsed once" not in text, relassert "REQ-W-001" in text, rel
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _commit → git_argv |
| REQ-DDB-CONFIG-003 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _root_source → declared_catalog → _is_flat_req_list |
| REQ-DDB-GUARD-012 | measured | test_exports_obey_the_audience → build_wiki → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-GUARD-024 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → _prose → impact_path → load_guard_config → read_guard_config → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-027 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _walk → _nested_specs → git_text |
| REQ-DDB-PIPE-003 | measured | |
| REQ-DDB-PIPE-004 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _all_flows → entry_point_flows → _scripts → console_scripts |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-QUERY-001 | measured | test_exports_obey_the_audience → build_wiki → _build_site → api_pages → connect |
| REQ-DDB-QUERY-003 | measured | test_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → table_exists |
| REQ-DDB-QUERY-004 | measured | test_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → _owners_by_file → file_owners |
| REQ-DDB-QUERY-010 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flow_page → derive_flow → _entry_rowids → function_candidates |
| REQ-DDB-QUERY-015 | measured | |
| REQ-DDB-SCHEMA-006 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _root_source → declared_catalog → resolve_catalog_path |
| REQ-DDB-SCHEMA-015 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _nodes → link_ids |
| REQ-DDB-WIKI-001 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flow_page → derive_flow |
| REQ-DDB-WIKI-002 | measured | test_exports_obey_the_audience → build_wiki → _build_site → parse_junit |
| REQ-DDB-WIKI-003 | measured | test_exports_obey_the_audience → build_wiki |
| REQ-DDB-WIKI-004 | measured | test_exports_obey_the_audience → build_wiki → _build_site → nodes_page |
| REQ-DDB-WIKI-005 | measured | test_exports_obey_the_audience → build_wiki → report_limit |
| REQ-DDB-WIKI-007 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → valid_key |
| REQ-DDB-WIKI-010 | measured | test_exports_obey_the_audience → build_wiki → _build_site → parse_features |
| REQ-DDB-WIKI-011 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _render → sphinx_settings |
| REQ-DDB-WIKI-012 | measured | test_exports_obey_the_audience → build_wiki → _build_site → requirements_page |
| REQ-DDB-WIKI-013 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _burndown → burndown |
| REQ-DDB-WIKI-014 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flow_page |
| REQ-DDB-WIKI-015 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _prose → impact_path |
| REQ-DDB-WIKI-016 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _coverage → parse_contexts |
| REQ-DDB-WIKI-017 | measured | |
| REQ-DDB-WIKI-018 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _all_flows → entry_point_flows |
| REQ-DDB-WIKI-019 | measured | test_exports_obey_the_audience → build_wiki → _build_site → build_graph |
| REQ-DDB-WIKI-020 | measured | test_exports_obey_the_audience → build_wiki → _build_site → write_quick_views → modal |
| REQ-DDB-WIKI-021 | measured | test_exports_obey_the_audience → build_wiki → _build_site → minimap_html |
| REQ-DDB-WIKI-022 | measured | test_exports_obey_the_audience → build_wiki → _build_site → requirements_page → requirement_pages |
| REQ-DDB-WIKI-023 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flows_index |
| REQ-DDB-WIKI-024 | measured | test_exports_obey_the_audience → build_wiki → _build_site → impact_page |
| REQ-DDB-WIKI-025 | measured | test_exports_obey_the_audience → build_wiki → _build_site → commit_published |
| REQ-DDB-WIKI-026 | measured | test_exports_obey_the_audience → build_wiki → _build_site → gather |
| REQ-DDB-WIKI-027 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _test_flows |
| REQ-DDB-WIKI-028 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _fetch_issues → provider_for |
| REQ-DDB-WIKI-029 | measured | test_exports_obey_the_audience → build_wiki → _build_site → write_exports |
| REQ-DDB-WIKI-031 | measured | test_exports_obey_the_audience → build_wiki → _build_site → find_decisions |
| REQ-DDB-WIKI-035 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flow_page → test_node |
| REQ-DDB-WIKI-036 | measured | test_exports_obey_the_audience → build_wiki → _build_site → root_name |
| REQ-DDB-WIKI-040 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose |
| REQ-DDB-WIKI-041 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _slices_by_test |
| REQ-DDB-WIKI-042 | measured | test_exports_obey_the_audience → build_wiki → _build_site → requirements_page → requirement_pages → _ears_line |
| REQ-DDB-WIKI-043 | measured | |
| REQ-DDB-WIKI-044 | measured | |
| REQ-DDB-WIKI-045 | measured | test_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → _section → _activity |
| REQ-DDB-WIKI-046 | measured | test_exports_obey_the_audience → build_wiki → _build_site → architecture_page |
| REQ-DDB-WIKI-047 | measured | test_exports_obey_the_audience → build_wiki → _build_site → _actor_of |
| REQ-DDB-WIKI-048 | measured | test_exports_obey_the_audience → build_wiki → _build_site → write_quick_views |
| REQ-DDB-WIKI-049 | inferred | test_exports_obey_the_audience → build_wiki → _build_site → flow_page → with_values |
| REQ-DDB-WIKI-050 | measured | test_exports_obey_the_audience → build_wiki → _build_site → flow_page |
| REQ-DDB-WIKI-051 | measured | test_exports_obey_the_audience → build_wiki → _build_site → sbom_page |
| REQ-DDB-WIKI-052 | measured | test_exports_obey_the_audience → build_wiki → _build_site → tests_index |
| REQ-DDB-WIKI-053 | measured | test_exports_obey_the_audience → build_wiki → _build_site → api_pages |
| REQ-DDB-WIKI-054 | inferred | test_exports_obey_the_audience → build_wiki → load_wiki_config → _comments → all |
Source · 11 lines
def test_exports_obey_the_audience(repo: tuple[Path, Path], tmp_path: Path) -> None: # noqa: F811
"""@brief `exclude_requirement_text` keeps titles and criteria out of every export."""
from clew.wiki.build import build_wiki
html = build_wiki(repo[0], repo[1], tmp_path / "out", audience="public")
for rel in ("exports/requirements.reqif", "exports/needs.json", "llms-full.txt"):
text = (html / rel).read_text()
assert "Load the data" not in text and "Every item is parsed once" not in text, rel
assert "REQ-W-001" in text, rel
Activity · 6 steps
test_flows_export_as_graphviz_dot
None test_wiki_exports.test_flows_export_as_graphviz_dot(dict[str, str] site)
P5.7 / S7: a flow as DOT, linked from its page.
Checks
assert dot.startswith("digraph ") and dot.rstrip().endswith("}")assert dot.count("subgraph cluster_") == 2 and 'label="src/data.py"' in dotassert '"load@src/data.py" -> "parse@src/data.py" [label="1"' in dotassert 'href="exports/flows/flow-load.dot"' in site["flow-load.html"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 15 lines
def test_flows_export_as_graphviz_dot(site: dict[str, str]) -> None: # noqa: F811
"""S7 (owner-approved 2026-11-17): Graphviz DOT beside Mermaid and PlantUML. DOT is a GRAPH
format, so a flow is drawn as one: each lane a cluster, each function a node in its lane, each
step an edge numbered in call order — the sequence survives as the numbers.
@brief P5.7 / S7: a flow as DOT, linked from its page.
"""
html = _html(site)
dot = (html / "exports/flows/flow-load.dot").read_text()
assert dot.startswith("digraph ") and dot.rstrip().endswith("}")
assert dot.count("subgraph cluster_") == 2 and 'label="src/data.py"' in dot
assert '"load@src/data.py" -> "parse@src/data.py" [label="1"' in dot
assert 'href="exports/flows/flow-load.dot"' in site["flow-load.html"]
Activity · 6 steps
test_flows_export_as_mermaid_and_plantuml
None test_wiki_exports.test_flows_export_as_mermaid_and_plantuml(dict[str, str] site)
Mermaid and PlantUML sequence diagrams with the loop frame, linked from the page.
Checks
assert mmd.startswith("sequenceDiagram") and "autonumber" in mmdassert "->>" in mmd and ": parse" in mmd and "loop" in mmd and "\n end" in mmdassert mmd.index("loop") < mmd.index(": parse") < mmd.index("end")assert puml.startswith("@startuml") and puml.rstrip().endswith("@enduml") and "loop" in pumlassert ('href="exports/flows/flow-load.mmd"' in page and 'href="exports/flows/flow-load.puml"' in page )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 16 lines
def test_flows_export_as_mermaid_and_plantuml(site: dict[str, str]) -> None: # noqa: F811
"""@brief Mermaid and PlantUML sequence diagrams with the loop frame, linked from the page."""
html = _html(site)
mmd = (html / "exports/flows/flow-load.mmd").read_text()
assert mmd.startswith("sequenceDiagram") and "autonumber" in mmd
assert "->>" in mmd and ": parse" in mmd and "loop" in mmd and "\n end" in mmd
assert mmd.index("loop") < mmd.index(": parse") < mmd.index("end")
puml = (html / "exports/flows/flow-load.puml").read_text()
assert puml.startswith("@startuml") and puml.rstrip().endswith("@enduml") and "loop" in puml
page = site["flow-load.html"]
assert (
'href="exports/flows/flow-load.mmd"' in page
and 'href="exports/flows/flow-load.puml"' in page
)
Activity · 9 steps
test_llms_txt_indexes_the_site_and_llms_full_carries_it
None test_wiki_exports.test_llms_txt_indexes_the_site_and_llms_full_carries_it(dict[str, str] site)
llms.txt (an H1, a summary quote, linked sections) and llms-full.txt (dense text).
Checks
assert index.startswith("# Site Demo\n") and "\n> " in indexassert ("## Requirements" in index and "(requirements.html)" in index and "(flow-load.html)" in index )assert "REQ-W-001" in full and "PASS" in full and "load -> parse" in full
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 14 lines
def test_llms_txt_indexes_the_site_and_llms_full_carries_it(site: dict[str, str]) -> None: # noqa: F811
"""@brief llms.txt (an H1, a summary quote, linked sections) and llms-full.txt (dense text)."""
html = _html(site)
index = (html / "llms.txt").read_text()
assert index.startswith("# Site Demo\n") and "\n> " in index
assert (
"## Requirements" in index
and "(requirements.html)" in index
and "(flow-load.html)" in index
)
full = (html / "llms-full.txt").read_text()
assert "REQ-W-001" in full and "PASS" in full and "load -> parse" in full
Activity · 6 steps
test_requirements_export_as_reqif
None test_wiki_exports.test_requirements_export_as_reqif(dict[str, str] site)
ReqIF 1.2: one SPEC-OBJECT per requirement with its id, title and tier.
Checks
assert root.tag == f"{_REQIF}REQ-IF"assert len(objects) == 3 and {"REQ-W-001", "Load the data", "PASS"} <= valuesassert root.findall(f".//{_REQIF}SPECIFICATION")
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 12 lines
def test_requirements_export_as_reqif(site: dict[str, str]) -> None: # noqa: F811
"""@brief ReqIF 1.2: one SPEC-OBJECT per requirement with its id, title and tier."""
root = ET.parse(_html(site) / "exports/requirements.reqif").getroot()
assert root.tag == f"{_REQIF}REQ-IF"
objects = root.findall(f".//{_REQIF}SPEC-OBJECT")
values = {
v.get("THE-VALUE") for o in objects for v in o.findall(f".//{_REQIF}ATTRIBUTE-VALUE-STRING")
}
assert len(objects) == 3 and {"REQ-W-001", "Load the data", "PASS"} <= values
assert root.findall(f".//{_REQIF}SPECIFICATION")
Activity · 6 steps
test_requirements_export_as_sphinx_needs
None test_wiki_exports.test_requirements_export_as_sphinx_needs(dict[str, str] site)
needs.json: a version holding one need per requirement, typed `req`.
Checks
assert need["type"] == "req" and need["title"] == "Load the data"assert "Every item is parsed once" in need["content"] and version["needs_amount"] == 3
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 9 lines
def test_requirements_export_as_sphinx_needs(site: dict[str, str]) -> None: # noqa: F811
"""@brief needs.json: a version holding one need per requirement, typed `req`."""
data = json.loads((_html(site) / "exports/needs.json").read_text())
version = data["versions"][data["current_version"]]
need = version["needs"]["REQ-W-001"]
assert need["type"] == "req" and need["title"] == "Load the data"
assert "Every item is parsed once" in need["content"] and version["needs_amount"] == 3
Activity · 5 steps
test_the_system_exports_as_structurizr
None test_wiki_exports.test_the_system_exports_as_structurizr(dict[str, str] site)
Structurizr DSL: a software system, a container per component, a relation per link.
Checks
assert dsl.startswith("workspace") and "softwareSystem" in dslassert 'container "src"' in dsl and "views" in dsl and "autolayout" in dsl
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-029 | catalog |
Source · 7 lines
def test_the_system_exports_as_structurizr(site: dict[str, str]) -> None: # noqa: F811
"""@brief Structurizr DSL: a software system, a container per component, a relation per link."""
dsl = (_html(site) / "exports/system.dsl").read_text()
assert dsl.startswith("workspace") and "softwareSystem" in dsl
assert 'container "src"' in dsl and "views" in dsl and "autolayout" in dsl