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.

tests/test_wiki_blocks.py:144

Checks

  • assert "Third-party" in ids and not any(is_vendor(i) for i in ids)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_declared_block_still_wins_over_vendor → build_graph → connect
REQ-DDB-QUERY-003measuredtest_a_declared_block_still_wins_over_vendor → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_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
lines 146–146from clew.wiki.graph import is_vendorlines 148–148declared = (*_DECLARED, ("Third-party", ("deps/*",)))lines 149–149ids = {c["id"] for c in build_graph(vendored_db, [], None, declared)["components"]}lines 150–150assert "Third-party" in ids and not any(is_vendor(i) for i in ids)

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.

tests/test_wiki_blocks.py:74

Show on the map →

Called by none

Calls build_graph

Checks

  • assert blocks["Unassigned"]["paths"] == ["pkg/lonely.py"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_file_coupled_to_no_declared_block_is_unassigned → build_graph → connect
REQ-DDB-QUERY-003measuredtest_a_file_coupled_to_no_declared_block_is_unassigned → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_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
lines 76–76blocks = {c["id"]: c for c in build_graph(db, [], None, _DECLARED)["components"]}lines 77–77assert blocks["Unassigned"]["paths"] == ["pkg/lonely.py"]

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.

tests/test_wiki_blocks.py:66

Show on the map →

Called by none

Calls build_graph

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

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_an_undeclared_file_joins_the_block_it_is_most_coupled_to → build_graph → connect
REQ-DDB-QUERY-003measuredtest_an_undeclared_file_joins_the_block_it_is_most_coupled_to → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_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
lines 68–68blocks = {c["id"]: c for c in build_graph(db, [], None, _DECLARED)["components"]}lines 69–69assert "pkg/util.py" in blocks["Core"]["paths"]lines 70–70assert blocks["Core"]["inferred_files"] == ["pkg/util.py"]lines 71–71assert blocks["API"]["inferred_files"] == []

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.

tests/test_wiki_blocks.py:129

Show on the map →

Called by none

Calls build_graph

Checks

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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_vendored_code_is_its_areas_block_never_joined_by_coupling → build_graph → connect
REQ-DDB-QUERY-003measuredtest_vendored_code_is_its_areas_block_never_joined_by_coupling → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_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
lines 131–131blocks = {c["id"]: c for c in build_graph(vendored_db, [], None, _DECLARED)["components"]}lines 132–132assert blocks[_ZLIB]["paths"] == ["deps/zlib/inflate.py", "deps/zlib/sub/crc.py"]lines 133–133assert blocks[_ZLIB]["vendor"] is Truelines 134–134assert not any(p.startswith("deps/") for p in blocks["Core"]["paths"])lines 135–135assert blocks[_ZLIB]["inferred_files"] == []

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.

tests/test_wiki_blocks.py:138

Show on the map →

Called by none

Calls build_graph

Checks

  • assert _ZLIB in ids and not any(i.startswith("deps") for i in ids)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_vendored_code_is_its_areas_block_with_nothing_declared → build_graph → connect
REQ-DDB-QUERY-003measuredtest_vendored_code_is_its_areas_block_with_nothing_declared → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_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
lines 140–140ids = {c["id"] for c in build_graph(vendored_db, [], None)["components"]}lines 141–141assert _ZLIB in ids and not any(i.startswith("deps") for i in ids)

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.

tests/test_wiki_blocks.py:80

Show on the map →

Called by none

Calls all, build_graph

Checks

  • assert all(c["inferred_files"] == [] for c in blocks)
  • assert "Unassigned" not in {c["id"] for c in blocks}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_with_nothing_declared_blocks_are_packages → build_graph → connect
REQ-DDB-QUERY-003measuredtest_with_nothing_declared_blocks_are_packages → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_with_nothing_declared_blocks_are_packages → build_graph
REQ-DDB-WIKI-054inferredtest_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}

Activity · 3 steps
lines 82–82blocks = build_graph(db, [], None)["components"]lines 83–83assert all(c["inferred_files"] == [] for c in blocks)lines 84–84assert "Unassigned" not in {c["id"] for c in blocks}