def test_find_connected_with_deps(self): member = _make_test_entity_member() dep_grph = \ build_resource_dependency_graph(self._interfaces, include_backrefs=True) ent_map = find_connected_resources(member, dependency_graph=dep_grph) # Backrefs should not make a difference since we check for duplicates. for ents in itervalues_(ent_map): self.assert_equal(len(ents), 1)
def test_dependency_graph(self): grph = build_resource_dependency_graph(self._interfaces) self.assert_equal(len(grph.nodes()), 4) entity_mb_cls = get_member_class(IMyEntity) entity_parent_mb_cls = get_member_class(IMyEntityParent) entity_child_mb_cls = get_member_class(IMyEntityChild) entity_grandchild_mb_cls = get_member_class(IMyEntityGrandchild) # Entity Parent resource deps should be empty. self.assert_equal(grph.neighbors(entity_parent_mb_cls), []) # Entity Child has Grandchild. self.assert_equal(grph.neighbors(entity_child_mb_cls), [entity_grandchild_mb_cls]) # Entity Grandchild has Child, but backrefs are excluded by default. self.assert_equal(grph.neighbors(entity_grandchild_mb_cls), []) # Entity has Parent and Child. self.assert_equal(set(grph.neighbors(entity_mb_cls)), set([entity_parent_mb_cls, entity_child_mb_cls]))