Fixes #3265 (now with Test Case)

- Added test_data_access_before_save_raises_error test
This commit is contained in:
paolopaolopaolo 2015-09-22 11:40:19 -07:00
parent 41b796d844
commit 134f5fa4bc

View File

@ -51,6 +51,15 @@ class TestSerializer:
with pytest.raises(AttributeError): with pytest.raises(AttributeError):
serializer.data serializer.data
def test_data_access_before_save_raises_error(self):
def create(validated_data):
return validated_data
serializer = self.Serializer(data={'char': 'abc', 'integer': 123})
serializer.create = create
assert serializer.is_valid()
assert serializer.data == {'char': 'abc', 'integer': 123}
with pytest.raises(AssertionError):
serializer.save()
class TestValidateMethod: class TestValidateMethod:
def test_non_field_error_validate_method(self): def test_non_field_error_validate_method(self):