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.
Checks
assert not problemsassert config.components == (("Query layer", ("clew/query/*",)), ("Server", ("clew/mcp_server/*",)), )assert load_wiki_config(tmp_path)[1]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_components_are_declared_in_the_wiki_section → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-021 | catalog | |
| REQ-DDB-WIKI-023 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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
test_package_lanes_are_the_maps_components
None test_wiki_map.test_package_lanes_are_the_maps_components(Path db)
P1e: package lanes.
Checks
assert [lane.id for lane in flow.lanes] == ["pkg/api", "pkg/core"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-QUERY-001 | measured | test_package_lanes_are_the_maps_components → derive_flow → connect |
| REQ-DDB-QUERY-003 | measured | test_package_lanes_are_the_maps_components → derive_flow → qualified_name_of |
| REQ-DDB-QUERY-010 | measured | test_package_lanes_are_the_maps_components → derive_flow → _entry_rowids → function_candidates |
| REQ-DDB-QUERY-015 | measured | |
| REQ-DDB-WIKI-001 | measured | test_package_lanes_are_the_maps_components → derive_flow |
| REQ-DDB-WIKI-019 | measured | |
| REQ-DDB-WIKI-021 | catalog | |
| REQ-DDB-WIKI-023 | catalog | |
| REQ-DDB-WIKI-041 | measured | test_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
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.
Checks
assert set(comps) == {"pkg/api", "pkg/core"}assert comps["pkg/core"]["tested_calls"] == 1 and comps["pkg/api"]["tested_calls"] == 0assert 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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_test_code_is_a_lens_not_a_box → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_test_code_is_a_lens_not_a_box → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_test_code_is_a_lens_not_a_box → build_graph |
| REQ-DDB-WIKI-021 | catalog | |
| REQ-DDB-WIKI-023 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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