def test_to_representation_none_value(self): instance = fields.EnumField(self.choices) self.assertEqual(instance.to_representation(None), None)
def test_to_representation_not_found_key(self): instance = fields.EnumField(self.choices) self.assertEqual(instance.to_representation(4), 4)
def test_to_representation_empty_string(self): instance = fields.EnumField(self.choices) self.assertEqual(instance.to_representation(''), '')
def test_to_representation(self): instance = fields.EnumField(self.choices) self.assertEqual(instance.to_representation(2), 2)
def test_to_internal_value_raise_validation_error(self): instance = fields.EnumField(self.choices) with self.assertRaises(ValidationError): instance.to_internal_value(4)
def test_to_internal_value_for_empty_string(self): instance = fields.EnumField(self.choices, allow_blank=True) self.assertEqual(instance.to_internal_value(''), '')
def test_to_internal_value(self): instance = fields.EnumField(choices=self.choices) self.assertEqual(instance.to_internal_value(1), 1)