mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Added tests for min_value and max_value on a DecimalField
This adds tests for a regression where the `min_value` and `max_value` arguments are not being set for a DRF `DecimalField` even though the corresponding `MinValueValidator` and `MaxValueValidator` is being set on the model fields. Note that this only appears to be a regression for Django < 1.9, as these regression tests pass on newer versions of Django.
This commit is contained in:
parent
2d27d9a10a
commit
9bab640b0a
|
@ -899,3 +899,29 @@ class TestDecimalFieldMappings(TestCase):
|
|||
serializer = TestSerializer()
|
||||
|
||||
assert len(serializer.fields['decimal_field'].validators) == 2
|
||||
|
||||
def test_min_value_is_passed(self):
|
||||
"""
|
||||
Test that the `MinValueValidator` is converted to the `min_value`
|
||||
argument for the field.
|
||||
"""
|
||||
class TestSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DecimalFieldModel
|
||||
|
||||
serializer = TestSerializer()
|
||||
|
||||
assert serializer.fields['decimal_field'].min_value == 1
|
||||
|
||||
def test_max_value_is_passed(self):
|
||||
"""
|
||||
Test that the `MaxValueValidator` is converted to the `max_value`
|
||||
argument for the field.
|
||||
"""
|
||||
class TestSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DecimalFieldModel
|
||||
|
||||
serializer = TestSerializer()
|
||||
|
||||
assert serializer.fields['decimal_field'].max_value == 3
|
||||
|
|
Loading…
Reference in New Issue
Block a user