Add test for unique together in a better place

This commit is contained in:
Bruno Alla 2024-09-11 22:50:55 +01:00
parent 81c74d903d
commit 2bf6c7df6d
No known key found for this signature in database

View File

@ -441,6 +441,14 @@ class TestUniquenessTogetherValidation(TestCase):
serializer = NullUniquenessTogetherSerializer(data=data)
assert serializer.is_valid()
def test_ignore_validation_for_missing_nullable_fields(self):
data = {
'date': datetime.date(2000, 1, 1),
'race_name': 'Paris Marathon',
}
serializer = NullUniquenessTogetherSerializer(data=data)
assert serializer.is_valid(), serializer.errors
def test_do_not_ignore_validation_for_null_fields(self):
# None values that are not on fields part of the uniqueness constraint
# do not cause the instance to skip validation.