Add test to repro duplicate validation error

Using the ModelSerializer with a model containing a GenericIPAddressField
produces duplicated validation error messages.
This commit is contained in:
Ryan Kaneshiro 2015-08-07 16:53:43 -07:00
parent 0cbfbc27d8
commit bc6bf7236b

View File

@ -344,6 +344,22 @@ class TestDurationFieldMapping(TestCase):
self.assertEqual(unicode_repr(TestSerializer()), expected)
class TestGenericIPAddressFieldValidation(TestCase):
def test_ip_address_validation(self):
class IPAddressFieldModel(models.Model):
address = models.GenericIPAddressField()
class TestSerializer(serializers.ModelSerializer):
class Meta:
model = IPAddressFieldModel
s = TestSerializer(data={'address': 'not an ip address'})
self.assertFalse(s.is_valid())
self.assertEquals(1, len(s.errors['address']),
'Unexpected number of validation errors: '
'{0}'.format(s.errors))
# Tests for relational field mappings.
# ------------------------------------