def test_get(self, test_name, PersonStatus): self.assertTrue( isinstance(PersonStatus.get(PersonStatus.ALIVE), Enum.Value)) self.assertTrue( isinstance(PersonStatus.get(six.text_type("ALIVE")), Enum.Value)) self.assertEqual( PersonStatus.get(PersonStatus.ALIVE), PersonStatus.get(six.text_type("ALIVE")), )
def test_enum_field_init(self, test_name, PersonStatus): field = EnumField(PersonStatus) self.assertEqual(field.default, PersonStatus.UNBORN) self.assertEqual(len(PersonStatus.choices()), len(field.choices)) field = EnumField(PersonStatus, default=PersonStatus.ALIVE) self.assertEqual(field.default, PersonStatus.ALIVE) field = EnumField(PersonStatus, default=None) self.assertEqual(field.default, None)
def test_equal(self, test_name, PersonStatus): self.assertTrue(PersonStatus.ALIVE == PersonStatus.ALIVE) self.assertFalse(PersonStatus.ALIVE == PersonStatus.DEAD) self.assertEqual(PersonStatus.get(PersonStatus.ALIVE), PersonStatus.get(PersonStatus.ALIVE))
def test_field(self, test_name, PersonStatus): self.assertTrue(isinstance(PersonStatus.field(), EnumField))
def test_default(self, test_name, PersonStatus): self.assertEqual(PersonStatus.default(), PersonStatus.UNBORN)
def test_choices_int(self): self.assertEqual( tuple(dict(list(PersonStatus.choices())).keys()), tuple(dict(list(PersonStatus.items())).values()), )
def test_choices(self, test_name, PersonStatus): self.assertEqual(len(PersonStatus.choices()), len(list(PersonStatus.items()))) self.assertTrue( all(key in PersonStatus.__dict__ for key in dict(list(PersonStatus.items()))))
def test_name(self, test_name, PersonStatus): self.assertEqual(PersonStatus.name(PersonStatus.ALIVE), six.text_type("ALIVE"))