MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _assert_same

Function _assert_same

tests/test_graph_invariance.py:76–88  ·  view source on GitHub ↗
(a: dict, b: dict, what: str)

Source from the content-addressed store, hash-verified

74
75
76def _assert_same(a: dict, b: dict, what: str) -> None:
77 keys_a = set(a) - {"__text__", "built_at_commit"}
78 keys_b = set(b) - {"__text__", "built_at_commit"}
79 assert keys_a == keys_b, f"{what} changed graph.json's top-level keys: {sorted(keys_a ^ keys_b)}"
80 nodes_a, edges_a = _canonical(a)
81 nodes_b, edges_b = _canonical(b)
82 only = {
83 "nodes only in the first": list((nodes_a - nodes_b).elements())[:5],
84 "nodes only in the second": list((nodes_b - nodes_a).elements())[:5],
85 "edges only in the first": list((edges_a - edges_b).elements())[:5],
86 "edges only in the second": list((edges_b - edges_a).elements())[:5],
87 }
88 assert not any(only.values()), f"{what} changed graph.json: " + json.dumps(only, indent=1)[:4000]
89
90
91@pytest.fixture(scope="module", params=[False, True], ids=["no_cluster", "clustered"])

Calls 1

_canonicalFunction · 0.70

Tested by

no test coverage detected