test_wiki_blocks.py¶
tests/test_wiki_blocks.py
Functional blocks: declared blocks win, the rest join them by coupling (round 4, R1).
test_a_declared_block_still_wins_over_vendor
None test_wiki_blocks.test_a_declared_block_still_wins_over_vendor(Path vendored_db)
A repo that names its vendored block keeps its own name for it.
Checks
assert "Third-party" in ids and not any(is_vendor(i) for i in ids)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_a_declared_block_still_wins_over_vendor → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_a_declared_block_still_wins_over_vendor → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_a_declared_block_still_wins_over_vendor → build_graph |
Source · 7 lines
def test_a_declared_block_still_wins_over_vendor(vendored_db: Path) -> None:
"""@brief A repo that names its vendored block keeps its own name for it."""
from clew.wiki.graph import is_vendor
declared = (*_DECLARED, ("Third-party", ("deps/*",)))
ids = {c["id"] for c in build_graph(vendored_db, [], None, declared)["components"]}
assert "Third-party" in ids and not any(is_vendor(i) for i in ids)1 more lines, not shown
Activity · 4 steps
test_a_file_coupled_to_no_declared_block_is_unassigned
None test_wiki_blocks.test_a_file_coupled_to_no_declared_block_is_unassigned(Path db)
pkg/lonely.py has no calls either way: it is Unassigned, never dropped.
Checks
assert blocks["Unassigned"]["paths"] == ["pkg/lonely.py"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_a_file_coupled_to_no_declared_block_is_unassigned → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_a_file_coupled_to_no_declared_block_is_unassigned → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_a_file_coupled_to_no_declared_block_is_unassigned → build_graph |
Source · 6 lines
def test_a_file_coupled_to_no_declared_block_is_unassigned(db: Path) -> None:
"""@brief pkg/lonely.py has no calls either way: it is Unassigned, never dropped."""
blocks = {c["id"]: c for c in build_graph(db, [], None, _DECLARED)["components"]}
assert blocks["Unassigned"]["paths"] == ["pkg/lonely.py"]
Activity · 2 steps
test_an_undeclared_file_joins_the_block_it_is_most_coupled_to
None test_wiki_blocks.test_an_undeclared_file_joins_the_block_it_is_most_coupled_to(Path db)
pkg/util.py is called only from Core, so it joins Core — labelled as inferred.
Checks
assert "pkg/util.py" in blocks["Core"]["paths"]assert blocks["Core"]["inferred_files"] == ["pkg/util.py"]assert blocks["API"]["inferred_files"] == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_an_undeclared_file_joins_the_block_it_is_most_coupled_to → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_an_undeclared_file_joins_the_block_it_is_most_coupled_to → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_an_undeclared_file_joins_the_block_it_is_most_coupled_to → build_graph |
Source · 8 lines
def test_an_undeclared_file_joins_the_block_it_is_most_coupled_to(db: Path) -> None:
"""@brief pkg/util.py is called only from Core, so it joins Core — labelled as inferred."""
blocks = {c["id"]: c for c in build_graph(db, [], None, _DECLARED)["components"]}
assert "pkg/util.py" in blocks["Core"]["paths"]
assert blocks["Core"]["inferred_files"] == ["pkg/util.py"]
assert blocks["API"]["inferred_files"] == []
Activity · 4 steps
test_vendored_code_is_its_areas_block_never_joined_by_coupling
None test_wiki_blocks.test_vendored_code_is_its_areas_block_never_joined_by_coupling(Path vendored_db)
deps/zlib is called only from Core, yet it is its own vendor block, not part of Core.
Checks
assert blocks[_ZLIB]["paths"] == ["deps/zlib/inflate.py", "deps/zlib/sub/crc.py"]assert blocks[_ZLIB]["vendor"] is Trueassert not any(p.startswith("deps/") for p in blocks["Core"]["paths"])assert blocks[_ZLIB]["inferred_files"] == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_vendored_code_is_its_areas_block_never_joined_by_coupling → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_vendored_code_is_its_areas_block_never_joined_by_coupling → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_vendored_code_is_its_areas_block_never_joined_by_coupling → build_graph |
Source · 9 lines
def test_vendored_code_is_its_areas_block_never_joined_by_coupling(vendored_db: Path) -> None:
"""@brief deps/zlib is called only from Core, yet it is its own vendor block, not part of Core."""
blocks = {c["id"]: c for c in build_graph(vendored_db, [], None, _DECLARED)["components"]}
assert blocks[_ZLIB]["paths"] == ["deps/zlib/inflate.py", "deps/zlib/sub/crc.py"]
assert blocks[_ZLIB]["vendor"] is True
assert not any(p.startswith("deps/") for p in blocks["Core"]["paths"])
assert blocks[_ZLIB]["inferred_files"] == []
Activity · 5 steps
test_vendored_code_is_its_areas_block_with_nothing_declared
None test_wiki_blocks.test_vendored_code_is_its_areas_block_with_nothing_declared(Path vendored_db)
No declaration: packages for first party, the vendor area its own block, not deps/zlib.
Checks
assert _ZLIB in ids and not any(i.startswith("deps") for i in ids)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_vendored_code_is_its_areas_block_with_nothing_declared → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_vendored_code_is_its_areas_block_with_nothing_declared → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_vendored_code_is_its_areas_block_with_nothing_declared → build_graph |
Source · 6 lines
def test_vendored_code_is_its_areas_block_with_nothing_declared(vendored_db: Path) -> None:
"""@brief No declaration: packages for first party, the vendor area its own block, not deps/zlib."""
ids = {c["id"] for c in build_graph(vendored_db, [], None)["components"]}
assert _ZLIB in ids and not any(i.startswith("deps") for i in ids)
Activity · 2 steps
test_with_nothing_declared_blocks_are_packages
None test_wiki_blocks.test_with_nothing_declared_blocks_are_packages(Path db)
No declaration: package blocks, and nothing is labelled inferred.
Checks
assert all(c["inferred_files"] == [] for c in blocks)assert "Unassigned" not in {c["id"] for c in blocks}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_with_nothing_declared_blocks_are_packages → build_graph → connect |
| REQ-DDB-QUERY-003 | measured | test_with_nothing_declared_blocks_are_packages → build_graph → _links → table_exists |
| REQ-DDB-WIKI-019 | measured | test_with_nothing_declared_blocks_are_packages → build_graph |
| REQ-DDB-WIKI-054 | inferred | test_with_nothing_declared_blocks_are_packages → all |
Source · 7 lines
def test_with_nothing_declared_blocks_are_packages(db: Path) -> None:
"""@brief No declaration: package blocks, and nothing is labelled inferred."""
blocks = build_graph(db, [], None)["components"]
assert all(c["inferred_files"] == [] for c in blocks)
assert "Unassigned" not in {c["id"] for c in blocks}