fix for minimu and maximum in validators, added validator for choices and choices param for BaseField, include tests

This commit is contained in:
collerek
2020-09-22 20:50:24 +02:00
parent 9620452b44
commit ebd812bf00
6 changed files with 202 additions and 15 deletions

View File

@ -28,6 +28,7 @@ class ExampleModel(Model):
test_json: fields.JSON(default={})
test_bigint: fields.BigInteger(default=0)
test_decimal: fields.Decimal(scale=10, precision=2)
test_decimal2: fields.Decimal(max_digits=10, decimal_places=2)
fields_to_check = [
@ -55,7 +56,7 @@ class ExampleModel2(Model):
@pytest.fixture()
def example():
return ExampleModel(
pk=1, test_string="test", test_bool=True, test_decimal=decimal.Decimal(3.5)
pk=1, test_string="test", test_bool=True, test_decimal=decimal.Decimal(3.5), test_decimal2=decimal.Decimal(5.5)
)
@ -73,6 +74,8 @@ def test_model_attribute_access(example):
assert example.test_float is None
assert example.test_bigint == 0
assert example.test_json == {}
assert example.test_decimal == 3.5
assert example.test_decimal2 == 5.5
example.test = 12
assert example.test == 12