def test_anchestor_registration2(self): """The anchestor registration doesn't mind cycles""" anchestors = AnchestorRegistration() anchestors.register_parent('child', 'parent') anchestors.register_parent('parent', 'child') self.assertTrue(anchestors.anchestor_of('child', 'parent')) self.assertTrue(anchestors.anchestor_of('parent', 'child'))
def test_anchestor_registration(self): """Check basic functionality""" anchestors = AnchestorRegistration() self.assertFalse(anchestors.anchestor_of('child', 'parent')) anchestors.register_parent('child', 'parent') self.assertTrue(anchestors.anchestor_of('child', 'parent')) anchestors.register_parent('grandchild', 'child') self.assertTrue(anchestors.anchestor_of('grandchild', 'parent')) self.assertFalse(anchestors.anchestor_of('parent', 'grandchild'))