test_wiki_map.py

tests/test_wiki_map.py

The system graph's components, as the repository web reads them (round 3, P1c-1; round 4).

test_components_are_declared_in_the_wiki_section

None test_wiki_map.test_components_are_declared_in_the_wiki_section(Path tmp_path)

`wiki.components`: name → globs, order kept; a malformed entry is a problem.

tests/test_wiki_map.py:84

Checks

  • assert not problems
  • assert config.components == (("Query layer", ("clew/query/*",)), ("Server", ("clew/mcp_server/*",)), )
  • assert load_wiki_config(tmp_path)[1]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_components_are_declared_in_the_wiki_section → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-021catalog
REQ-DDB-WIKI-023catalog
REQ-DDB-WIKI-054inferredtest_components_are_declared_in_the_wiki_section → load_wiki_config → _comments → all
Source · 17 lines
def test_components_are_declared_in_the_wiki_section(tmp_path: Path) -> None:
    """@brief `wiki.components`: name → globs, order kept; a malformed entry is a problem."""
    from clew.wiki.config import load_wiki_config

    (tmp_path / ".clew.yaml").write_text(
        "wiki:\n  components:\n    Query layer: [clew/query/*]\n    Server: [clew/mcp_server/*]\n"
    )
    config, problems = load_wiki_config(tmp_path)
    assert not problems
    assert config.components == (
        ("Query layer", ("clew/query/*",)),
        ("Server", ("clew/mcp_server/*",)),
    )
    (tmp_path / ".clew.yaml").write_text("wiki:\n  components: [a, b]\n")
    assert load_wiki_config(tmp_path)[1]

Activity · 7 steps
lines 86–86from clew.wiki.config import load_wiki_configlines 88–90(tmp_path / ".clew.yaml").write_text( "wiki:\n components:\n Query layer: [clew/query/*]\n Server: [clew/mcp_server/*]\n" )lines 91–91config, problems = load_wiki_config(tmp_path)lines 92–92assert not problemslines 93–96assert config.components == ( ("Query layer", ("clew/query/*",)), ("Server", ("clew/mcp_server/*",)), )lines 97–97(tmp_path / ".clew.yaml").write_text("wiki:\n components: [a, b]\n")lines 98–98assert load_wiki_config(tmp_path)[1]

test_package_lanes_are_the_maps_components

None test_wiki_map.test_package_lanes_are_the_maps_components(Path db)

P1e: package lanes.

tests/test_wiki_map.py:101

Show on the map →

Called by none

Calls derive_flow

Checks

  • assert [lane.id for lane in flow.lanes] == ["pkg/api", "pkg/core"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measured
REQ-DDB-QUERY-001measuredtest_package_lanes_are_the_maps_components → derive_flow → connect
REQ-DDB-QUERY-003measuredtest_package_lanes_are_the_maps_components → derive_flow → qualified_name_of
REQ-DDB-QUERY-010measuredtest_package_lanes_are_the_maps_components → derive_flow → _entry_rowids → function_candidates
REQ-DDB-QUERY-015measured
REQ-DDB-WIKI-001measuredtest_package_lanes_are_the_maps_components → derive_flow
REQ-DDB-WIKI-019measured
REQ-DDB-WIKI-021catalog
REQ-DDB-WIKI-023catalog
REQ-DDB-WIKI-041measuredtest_package_lanes_are_the_maps_components → derive_flow
Source · 11 lines
def test_package_lanes_are_the_maps_components(db: Path) -> None:
    """THE SAME RULE AS THE MAP: `pkg/api/handlers.py` is in lane `pkg/api`, not `pkg` — a flow
    inside one top-level package no longer collapses to a single lane.

    @brief P1e: package lanes.
    """
    from clew.wiki.flow import derive_flow

    repo = db.parent / "repo"
    flow = derive_flow(db, repo, "handle", depth=1, lanes="packages")
    assert [lane.id for lane in flow.lanes] == ["pkg/api", "pkg/core"]

1 more lines, not shown

Activity · 4 steps
lines 107–107from clew.wiki.flow import derive_flowlines 109–109repo = db.parent / "repo"lines 110–110flow = derive_flow(db, repo, "handle", depth=1, lanes="packages")lines 111–111assert [lane.id for lane in flow.lanes] == ["pkg/api", "pkg/core"]

test_test_code_is_a_lens_not_a_box

None test_wiki_map.test_test_code_is_a_lens_not_a_box(Path db)

Graph: test exclusion.

tests/test_wiki_map.py:70

Show on the map →

Called by none

Calls all, build_graph

Checks

  • assert set(comps) == {"pkg/api", "pkg/core"}
  • assert comps["pkg/core"]["tested_calls"] == 1 and comps["pkg/api"]["tested_calls"] == 0
  • assert all(p["file"].startswith("pkg/") for p in graph["symbols"])
  • assert comps["pkg/api"]["y"] == 0 and comps["pkg/core"]["y"] > 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_test_code_is_a_lens_not_a_box → build_graph → connect
REQ-DDB-QUERY-003measuredtest_test_code_is_a_lens_not_a_box → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_test_code_is_a_lens_not_a_box → build_graph
REQ-DDB-WIKI-021catalog
REQ-DDB-WIKI-023catalog
REQ-DDB-WIKI-054inferredtest_test_code_is_a_lens_not_a_box → all
Source · 14 lines
def test_test_code_is_a_lens_not_a_box(db: Path) -> None:
    """`exclude_tests` drops test-only components from the layout and counts the calls test code
    makes into each remaining component as `tested_calls`.

    @brief Graph: test exclusion.
    """
    graph = build_graph(db, _EVIDENCE, None, exclude_tests=True)
    comps = {c["id"]: c for c in graph["components"]}
    assert set(comps) == {"pkg/api", "pkg/core"}
    assert comps["pkg/core"]["tested_calls"] == 1 and comps["pkg/api"]["tested_calls"] == 0
    assert all(p["file"].startswith("pkg/") for p in graph["symbols"])
    assert comps["pkg/api"]["y"] == 0 and comps["pkg/core"]["y"] > 0

Activity · 6 steps
lines 76–76graph = build_graph(db, _EVIDENCE, None, exclude_tests=True)lines 77–77comps = {c["id"]: c for c in graph["components"]}lines 78–78assert set(comps) == {"pkg/api", "pkg/core"}lines 79–79assert comps["pkg/core"]["tested_calls"] == 1 and comps["pkg/api"]["tested_calls"] == 0lines 80–80assert all(p["file"].startswith("pkg/") for p in graph["symbols"])lines 81–81assert comps["pkg/api"]["y"] == 0 and comps["pkg/core"]["y"] > 0