def test_should_find_components_with_same_attributes_in_list(self): componentinstance = ComponentModel(FakeObj, [], LifeStyle.transient()) componentinstance2nd = ComponentModel(FakeObj, [], LifeStyle.transient()) componentset = ComponentSet() componentset.add(componentinstance) assert componentset.has_comp(componentinstance2nd)
def test_should_prevent_storing_duplicate_attributes_of_componentmodel(self): componentset = ComponentSet() componentinstance = ComponentModel(FakeObj, [], LifeStyle.transient()) componentinstance2nd = ComponentModel(FakeObj, [], LifeStyle.transient()) componentset.add(componentinstance) try: componentset.add(componentinstance2nd) self.fail("should not happen") except AttemptToAddDuplicateComponentModelToVisitedSet: pass
def test_should_prevent_storing_duplicate_attributes_of_componentmodel( self): componentset = ComponentSet() componentinstance = ComponentModel(FakeObj, [], LifeStyle.transient()) componentinstance2nd = ComponentModel(FakeObj, [], LifeStyle.transient()) componentset.add(componentinstance) try: componentset.add(componentinstance2nd) self.fail("should not happen") except AttemptToAddDuplicateComponentModelToVisitedSet: pass
def resolve(self, clstype=None, key=None): """standard client way of accessing Components""" visitedset = ComponentSet() obj = self.__resolver.recursewalk(self.__objectgraph, key, clstype, self.__instances, visitedset) return obj