def test_no_issues(self): assert_no_cycles([ ("State", 'TOP'), ("County", "State"), ("City", "County"), ("Region", "State"), ("District", "Region"), ])
def test_bad_parent_ref(self): with self.assertRaises(TreeError) as e: assert_no_cycles([ ("County", "State"), # State doesn't exist ("City", "County"), ("Region", "State"), # State doesn't exist ("District", "Region"), ]) self.assertItemsEqual( e.exception.affected_nodes, ["County", "Region"] )
def test_has_cycle(self): with self.assertRaises(TreeError) as e: assert_no_cycles([ ("State", 'TOP'), ("County", "State"), ("City", "County"), # These three cycle: ("Region", "Village"), ("District", "Region"), ("Village", "District"), ]) self.assertItemsEqual(e.exception.affected_nodes, ["Region", "District", "Village"])
def test_has_cycle(self): with self.assertRaises(TreeError) as e: assert_no_cycles([ ("State", 'TOP'), ("County", "State"), ("City", "County"), # These three cycle: ("Region", "Village"), ("District", "Region"), ("Village", "District"), ]) self.assertItemsEqual( e.exception.affected_nodes, ["Region", "District", "Village"] )