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

Show on the map →

Called by none

Calls _dot_id

Checks

  • assert _dot_id('a"b\\c') == '"a\\"b\\\\c"'

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 115–115from clew.wiki.exports import _dot_idlines 117–117assert _dot_id('a"b\\c') == '"a\\"b\\\\c"'

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.

tests/test_wiki_exports.py:87

Show on the map →

Called by none

Calls build_wiki

Checks

  • assert "Load the data" not in text and "Every item is parsed once" not in text, rel
  • assert "REQ-W-001" in text, rel

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_exports_obey_the_audience → build_wiki → _build_site → _commit → git_argv
REQ-DDB-CONFIG-003measuredtest_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _root_source → declared_catalog → _is_flat_req_list
REQ-DDB-GUARD-012measuredtest_exports_obey_the_audience → build_wiki → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-GUARD-024inferredtest_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-027inferredtest_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _walk → _nested_specs → git_text
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measuredtest_exports_obey_the_audience → build_wiki → _build_site → _all_flows → entry_point_flows → _scripts → console_scripts
REQ-DDB-PIPE-011measured
REQ-DDB-QUERY-001measuredtest_exports_obey_the_audience → build_wiki → _build_site → api_pages → connect
REQ-DDB-QUERY-003measuredtest_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → table_exists
REQ-DDB-QUERY-004measuredtest_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → _owners_by_file → file_owners
REQ-DDB-QUERY-010measuredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page → derive_flow → _entry_rowids → function_candidates
REQ-DDB-QUERY-015measured
REQ-DDB-SCHEMA-006measuredtest_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _root_source → declared_catalog → resolve_catalog_path
REQ-DDB-SCHEMA-015inferredtest_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose → _nodes → link_ids
REQ-DDB-WIKI-001measuredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page → derive_flow
REQ-DDB-WIKI-002measuredtest_exports_obey_the_audience → build_wiki → _build_site → parse_junit
REQ-DDB-WIKI-003measuredtest_exports_obey_the_audience → build_wiki
REQ-DDB-WIKI-004measuredtest_exports_obey_the_audience → build_wiki → _build_site → nodes_page
REQ-DDB-WIKI-005measuredtest_exports_obey_the_audience → build_wiki → report_limit
REQ-DDB-WIKI-007inferredtest_exports_obey_the_audience → build_wiki → _build_site → valid_key
REQ-DDB-WIKI-010measuredtest_exports_obey_the_audience → build_wiki → _build_site → parse_features
REQ-DDB-WIKI-011measuredtest_exports_obey_the_audience → build_wiki → _build_site → _render → sphinx_settings
REQ-DDB-WIKI-012measuredtest_exports_obey_the_audience → build_wiki → _build_site → requirements_page
REQ-DDB-WIKI-013measuredtest_exports_obey_the_audience → build_wiki → _build_site → _burndown → burndown
REQ-DDB-WIKI-014measuredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page
REQ-DDB-WIKI-015measuredtest_exports_obey_the_audience → build_wiki → _build_site → _prose → impact_path
REQ-DDB-WIKI-016measuredtest_exports_obey_the_audience → build_wiki → _build_site → _coverage → parse_contexts
REQ-DDB-WIKI-017measured
REQ-DDB-WIKI-018measuredtest_exports_obey_the_audience → build_wiki → _build_site → _all_flows → entry_point_flows
REQ-DDB-WIKI-019measuredtest_exports_obey_the_audience → build_wiki → _build_site → build_graph
REQ-DDB-WIKI-020measuredtest_exports_obey_the_audience → build_wiki → _build_site → write_quick_views → modal
REQ-DDB-WIKI-021measuredtest_exports_obey_the_audience → build_wiki → _build_site → minimap_html
REQ-DDB-WIKI-022measuredtest_exports_obey_the_audience → build_wiki → _build_site → requirements_page → requirement_pages
REQ-DDB-WIKI-023measuredtest_exports_obey_the_audience → build_wiki → _build_site → flows_index
REQ-DDB-WIKI-024measuredtest_exports_obey_the_audience → build_wiki → _build_site → impact_page
REQ-DDB-WIKI-025measuredtest_exports_obey_the_audience → build_wiki → _build_site → commit_published
REQ-DDB-WIKI-026measuredtest_exports_obey_the_audience → build_wiki → _build_site → gather
REQ-DDB-WIKI-027measuredtest_exports_obey_the_audience → build_wiki → _build_site → _test_flows
REQ-DDB-WIKI-028measuredtest_exports_obey_the_audience → build_wiki → _build_site → _fetch_issues → provider_for
REQ-DDB-WIKI-029measuredtest_exports_obey_the_audience → build_wiki → _build_site → write_exports
REQ-DDB-WIKI-031measuredtest_exports_obey_the_audience → build_wiki → _build_site → find_decisions
REQ-DDB-WIKI-035measuredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page → test_node
REQ-DDB-WIKI-036measuredtest_exports_obey_the_audience → build_wiki → _build_site → root_name
REQ-DDB-WIKI-040inferredtest_exports_obey_the_audience → build_wiki → _build_site → _product_section → compose
REQ-DDB-WIKI-041measuredtest_exports_obey_the_audience → build_wiki → _build_site → _slices_by_test
REQ-DDB-WIKI-042measuredtest_exports_obey_the_audience → build_wiki → _build_site → requirements_page → requirement_pages → _ears_line
REQ-DDB-WIKI-043measured
REQ-DDB-WIKI-044measured
REQ-DDB-WIKI-045measuredtest_exports_obey_the_audience → build_wiki → _build_site → symbol_pages → _section → _activity
REQ-DDB-WIKI-046measuredtest_exports_obey_the_audience → build_wiki → _build_site → architecture_page
REQ-DDB-WIKI-047measuredtest_exports_obey_the_audience → build_wiki → _build_site → _actor_of
REQ-DDB-WIKI-048measuredtest_exports_obey_the_audience → build_wiki → _build_site → write_quick_views
REQ-DDB-WIKI-049inferredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page → with_values
REQ-DDB-WIKI-050measuredtest_exports_obey_the_audience → build_wiki → _build_site → flow_page
REQ-DDB-WIKI-051measuredtest_exports_obey_the_audience → build_wiki → _build_site → sbom_page
REQ-DDB-WIKI-052measuredtest_exports_obey_the_audience → build_wiki → _build_site → tests_index
REQ-DDB-WIKI-053measuredtest_exports_obey_the_audience → build_wiki → _build_site → api_pages
REQ-DDB-WIKI-054inferredtest_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
lines 89–89from clew.wiki.build import build_wikilines 91–91html = build_wiki(repo[0], repo[1], tmp_path / "out", audience="public")lines 92–92◇ for rel in ("exports/requirements.reqif", "exports/needs.json", "llms-full.txt")lines 93–93text = (html / rel).read_text()lines 94–94assert "Load the data" not in text and "Every item is parsed once" not in text, rellines 95–95assert "REQ-W-001" in text, rel

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.

tests/test_wiki_exports.py:98

Show on the map →

Called by none

Calls _html

Checks

  • 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"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 105–105html = _html(site)lines 106–106dot = (html / "exports/flows/flow-load.dot").read_text()lines 107–107assert dot.startswith("digraph ") and dot.rstrip().endswith("}")lines 108–108assert dot.count("subgraph cluster_") == 2 and 'label="src/data.py"' in dotlines 109–109assert '"load@src/data.py" -> "parse@src/data.py" [label="1"' in dotlines 110–110assert 'href="exports/flows/flow-load.dot"' in site["flow-load.html"]

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.

tests/test_wiki_exports.py:29

Show on the map →

Called by none

Calls _html

Checks

  • 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")
  • assert puml.startswith("@startuml") and puml.rstrip().endswith("@enduml") and "loop" in puml
  • assert ('href="exports/flows/flow-load.mmd"' in page and 'href="exports/flows/flow-load.puml"' in page )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 31–31html = _html(site)lines 32–32mmd = (html / "exports/flows/flow-load.mmd").read_text()lines 33–33assert mmd.startswith("sequenceDiagram") and "autonumber" in mmdlines 34–34assert "->>" in mmd and ": parse" in mmd and "loop" in mmd and "\n end" in mmdlines 35–35assert mmd.index("loop") < mmd.index(": parse") < mmd.index("end")lines 36–36puml = (html / "exports/flows/flow-load.puml").read_text()lines 37–37assert puml.startswith("@startuml") and puml.rstrip().endswith("@enduml") and "loop" in pumllines 38–38page = site["flow-load.html"]lines 39–42assert ( 'href="exports/flows/flow-load.mmd"' in page and 'href="exports/flows/flow-load.puml"' in page )

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).

tests/test_wiki_exports.py:45

Show on the map →

Called by none

Calls _html

Checks

  • 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 )
  • assert "REQ-W-001" in full and "PASS" in full and "load -> parse" in full

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 47–47html = _html(site)lines 48–48index = (html / "llms.txt").read_text()lines 49–49assert index.startswith("# Site Demo\n") and "\n> " in indexlines 50–54assert ( "## Requirements" in index and "(requirements.html)" in index and "(flow-load.html)" in index )lines 55–55full = (html / "llms-full.txt").read_text()lines 56–56assert "REQ-W-001" in full and "PASS" in full and "load -> parse" in full

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.

tests/test_wiki_exports.py:59

Show on the map →

Called by none

Calls _html

Checks

  • assert root.tag == f"{_REQIF}REQ-IF"
  • assert len(objects) == 3 and {"REQ-W-001", "Load the data", "PASS"} <= values
  • assert root.findall(f".//{_REQIF}SPECIFICATION")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 61–61root = ET.parse(_html(site) / "exports/requirements.reqif").getroot()lines 62–62assert root.tag == f"{_REQIF}REQ-IF"lines 63–63objects = root.findall(f".//{_REQIF}SPEC-OBJECT")lines 64–66values = { v.get("THE-VALUE") for o in objects for v in o.findall(f".//{_REQIF}ATTRIBUTE-VALUE-STRING") }lines 67–67assert len(objects) == 3 and {"REQ-W-001", "Load the data", "PASS"} <= valueslines 68–68assert root.findall(f".//{_REQIF}SPECIFICATION")

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`.

tests/test_wiki_exports.py:71

Show on the map →

Called by none

Calls _html

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

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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
lines 73–73data = json.loads((_html(site) / "exports/needs.json").read_text())lines 74–74version = data["versions"][data["current_version"]]lines 75–75need = version["needs"]["REQ-W-001"]lines 76–76assert need["type"] == "req" and need["title"] == "Load the data"lines 77–77assert "Every item is parsed once" in need["content"] and version["needs_amount"] == 3

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.

tests/test_wiki_exports.py:80

Show on the map →

Called by none

Calls _html

Checks

  • assert dsl.startswith("workspace") and "softwareSystem" in dsl
  • assert 'container "src"' in dsl and "views" in dsl and "autolayout" in dsl

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-029catalog
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

Activity · 3 steps
lines 82–82dsl = (_html(site) / "exports/system.dsl").read_text()lines 83–83assert dsl.startswith("workspace") and "softwareSystem" in dsllines 84–84assert 'container "src"' in dsl and "views" in dsl and "autolayout" in dsl