test_wiki_graph.py

tests/test_wiki_graph.py

The wiki's system graph (round 3, P1a): one typed model at several zoom levels.

test_a_file_belongs_to_its_package_unless_a_grouping_is_declared

None test_wiki_graph.test_a_file_belongs_to_its_package_unless_a_grouping_is_declared()

Component rules.

tests/test_wiki_graph.py:67

Checks

  • assert component_of("clew/query/x.py") == "clew/query"
  • assert component_of("clew/cli.py") == "clew"
  • assert component_of("setup.py") == "(root)"
  • assert component_of("clew/query/x.py", (("Query layer", ("clew/query/*",)),)) == "Query layer"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-019measuredtest_a_file_belongs_to_its_package_unless_a_grouping_is_declared → component_of
Source · 8 lines
def test_a_file_belongs_to_its_package_unless_a_grouping_is_declared() -> None:
    """@brief Component rules."""
    assert component_of("clew/query/x.py") == "clew/query"
    assert component_of("clew/cli.py") == "clew"
    assert component_of("setup.py") == "(root)"
    assert component_of("clew/query/x.py", (("Query layer", ("clew/query/*",)),)) == "Query layer"

Activity · 4 steps
lines 69–69assert component_of("clew/query/x.py") == "clew/query"lines 70–70assert component_of("clew/cli.py") == "clew"lines 71–71assert component_of("setup.py") == "(root)"lines 72–72assert component_of("clew/query/x.py", (("Query layer", ("clew/query/*",)),)) == "Query layer"

test_lens_facts_ride_on_components_and_absent_sources_stay_absent

None test_wiki_graph.test_lens_facts_ride_on_components_and_absent_sources_stay_absent(Path db)

Lens facts.

tests/test_wiki_graph.py:91

Show on the map →

Called by none

Calls all, build_graph

Checks

  • assert plain["pkg/core"]["requirements"] == {"PASS": 1}
  • assert "requirements" not in plain["pkg/api"]
  • assert all("changed" not in c for c in plain.values())
  • assert measured["pkg/core"]["changed"] == 1 and measured["pkg/api"]["changed"] == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_lens_facts_ride_on_components_and_absent_sources_stay_absent → build_graph → connect
REQ-DDB-QUERY-003measuredtest_lens_facts_ride_on_components_and_absent_sources_stay_absent → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_lens_facts_ride_on_components_and_absent_sources_stay_absent → build_graph
REQ-DDB-WIKI-054inferredtest_lens_facts_ride_on_components_and_absent_sources_stay_absent → all
Source · 15 lines
def test_lens_facts_ride_on_components_and_absent_sources_stay_absent(db: Path) -> None:
    """NO IMPACT REPORT, NO `changed` KEY; an empty report is a measured zero everywhere.

    @brief Lens facts.
    """
    evidence = [_Row("R-1", "PASS", (("save", "pkg/core/store.py", 1),))]
    plain = {c["id"]: c for c in build_graph(db, evidence, None)["components"]}
    assert plain["pkg/core"]["requirements"] == {"PASS": 1}
    assert "requirements" not in plain["pkg/api"]
    assert all("changed" not in c for c in plain.values())
    impact = [{"req_id": "R-1", "functions": [{"name": "save", "file": "pkg/core/store.py"}]}]
    measured = {c["id"]: c for c in build_graph(db, evidence, impact)["components"]}
    assert measured["pkg/core"]["changed"] == 1 and measured["pkg/api"]["changed"] == 0

Activity · 8 steps
lines 96–96evidence = [_Row("R-1", "PASS", (("save", "pkg/core/store.py", 1),))]lines 97–97plain = {c["id"]: c for c in build_graph(db, evidence, None)["components"]}lines 98–98assert plain["pkg/core"]["requirements"] == {"PASS": 1}lines 99–99assert "requirements" not in plain["pkg/api"]lines 100–100assert all("changed" not in c for c in plain.values())lines 101–101impact = [{"req_id": "R-1", "functions": [{"name": "save", "file": "pkg/core/store.py"}]}]lines 102–102measured = {c["id"]: c for c in build_graph(db, evidence, impact)["components"]}lines 103–103assert measured["pkg/core"]["changed"] == 1 and measured["pkg/api"]["changed"] == 0

test_the_point_cloud_places_every_function_inside_its_box

None test_wiki_graph.test_the_point_cloud_places_every_function_inside_its_box(Path db)

Code level.

tests/test_wiki_graph.py:106

Show on the map →

Called by none

Calls build_graph

Checks

  • assert box is not None
  • assert save["tier"] == "PASS" and "changed" not in save

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_the_point_cloud_places_every_function_inside_its_box → build_graph → connect
REQ-DDB-QUERY-003measuredtest_the_point_cloud_places_every_function_inside_its_box → build_graph → _links → table_exists
REQ-DDB-WIKI-019measuredtest_the_point_cloud_places_every_function_inside_its_box → build_graph
Source · 13 lines
def test_the_point_cloud_places_every_function_inside_its_box(db: Path) -> None:
    """@brief Code level."""
    graph = build_graph(db, [_Row("R-1", "PASS", (("save", "pkg/core/store.py", 1),))], None)
    comps = {c["id"]: c for c in graph["components"]}
    for point in graph["symbols"]:
        box = next(
            c
            for c in comps.values()
            if c["x"] <= point["x"] <= c["x"] + c["w"] and c["y"] <= point["y"] <= c["y"] + c["h"]
        )
        assert box is not None
    save = next(p for p in graph["symbols"] if p["name"] == "save")
    assert save["tier"] == "PASS" and "changed" not in save

1 more lines, not shown

Activity · 7 steps
lines 108–108graph = build_graph(db, [_Row("R-1", "PASS", (("save", "pkg/core/store.py", 1),))], None)lines 109–109comps = {c["id"]: c for c in graph["components"]}lines 110–110◇ for point in graph["symbols"]lines 111–115box = next( c for c in comps.values() if c["x"] <= point["x"] <= c["x"] + c["w"] and c["y"] <= point["y"] <= c["y"] + c["h"] )lines 116–116assert box is not Nonelines 117–117save = next(p for p in graph["symbols"] if p["name"] == "save")lines 118–118assert save["tier"] == "PASS" and "changed" not in save