def test_supplier_groups_inner_cycle(): nodes = ["x1", "x2", "x3"] edges = [("x1", "x2"), ("x2", "x3"), ("x3", "x2")] nodes = { n: Node(logic=dict(), tags=frozenset(["supplier"])) for n in nodes } nodes.update({"indicator": Node(tags=frozenset(["indicator"]))}) sg = SystemGraph(nodes=nodes, edges=[Edge(src=s, dst=d) for s, d in edges]) assert len(sg.supplier_groups) == 0
def test_supplier_groups_basic(): nodes = ["x1", "x2", "x3", "x4", "x5", "x6"] edges = [("x1", "x2"), ("x2", "x3"), ("x4", "x5"), ("x4", "x6")] nodes = { n: Node(logic=dict(), tags=frozenset(["supplier"])) for n in nodes } nodes.update({"indicator": Node(tags=frozenset(["indicator"]))}) sg = SystemGraph(nodes=nodes, edges=[Edge(src=s, dst=d) for s, d in edges]) expected = {"x1": {"x1", "x2", "x3"}, "x4": {"x4", "x5", "x6"}} assert sg.supplier_groups == expected
def test_sg_hash_very_close_extra_node(minimal: SystemGraph): other = copy.deepcopy(minimal) pre = hash(minimal) other.nodes["new"] = Node() assert pre != hash(other)