def test_is_of_false_unrelated(self): t_liquid = RxType("liquid") t_solid = RxType("solid") type_set = RxTypeSet() type_set._types = {"liquid": t_liquid, "solid": t_solid} self.assertFalse(type_set.is_of("solid", "liquid")) self.assertFalse(type_set.is_of("liquid", "solid"))
def test_is_one_of_false_hierarchy(self): t_liquid = RxType("liquid") t_water = RxType("water", t_liquid) t_lake = RxType("lake", t_water) type_set = RxTypeSet() type_set._types = {"liquid": t_liquid} self.assertFalse(type_set.is_one_of("liquid", ["water", "lake"]))
def test_is_of_excluded(self): t_liquid = RxType("liquid") t_water = RxType("water", t_liquid) type_set = RxTypeSet() type_set._types = {"liquid": t_liquid} with self.assertRaises(KeyError): type_set.is_of("water", "liquid")
def test_is_one_of_false_unrelated(self): t_liquid = RxType("liquid") t_solid = RxType("solid") t_gas = RxType("gas") t_plasma = RxType("plasma") type_set = RxTypeSet() type_set._types = {"plasma": t_plasma} self.assertFalse( type_set.is_one_of("plasma", ["liquid", "solid", "gas"]))
def test_is_one_of_true(self): t_liquid = RxType("liquid") t_solid = RxType("solid") t_gas = RxType("gas") t_water = RxType("water", t_liquid) type_set = RxTypeSet() type_set._types = {"water": t_water} self.assertTrue(type_set.is_one_of("water", ["liquid", "solid", "gas"]))
def test_is_of_true(self): t_liquid = RxType("liquid") t_water = RxType("water", t_liquid) t_lake = RxType("lake", t_water) type_set = RxTypeSet() type_set._types = {"water": t_water, "lake": t_lake} self.assertTrue(type_set.is_of("water", "liquid")) self.assertTrue(type_set.is_of("lake", "water"))
def test_get_full_type_names(self): t_liquid = RxType("liquid") t_water = RxType("water", t_liquid) t_lake = RxType("lake", t_water) type_set = RxTypeSet() type_set._types = { "liquid": t_liquid, "water": t_water, "lake": t_lake } self.assertEqual(type_set.get_full_type_names("liquid"), ["liquid"]) self.assertEqual(type_set.get_full_type_names("water"), ["water", "liquid"]) self.assertEqual(type_set.get_full_type_names("lake"), ["lake", "water", "liquid"])
def test_getitem(self): rxtype = RxType("liquid") type_set = RxTypeSet() type_set._types = {"liquid": rxtype} self.assertEqual(type_set["liquid"], rxtype)