Fixed DecimalField bug
This commit is contained in:
parent
207fd9fcb7
commit
90200dbe9c
3 changed files with 32 additions and 2 deletions
|
|
@ -136,12 +136,16 @@ class FieldTest(unittest.TestCase):
|
|||
height = DecimalField(min_value=Decimal('0.1'),
|
||||
max_value=Decimal('3.5'))
|
||||
|
||||
Person.drop_collection()
|
||||
|
||||
person = Person()
|
||||
person.height = Decimal('1.89')
|
||||
person.validate()
|
||||
person.save()
|
||||
person.reload()
|
||||
self.assertEqual(person.height, Decimal('1.89'))
|
||||
|
||||
person.height = '2.0'
|
||||
person.validate()
|
||||
person.save()
|
||||
person.height = 0.01
|
||||
self.assertRaises(ValidationError, person.validate)
|
||||
person.height = Decimal('0.01')
|
||||
|
|
@ -149,6 +153,8 @@ class FieldTest(unittest.TestCase):
|
|||
person.height = Decimal('4.0')
|
||||
self.assertRaises(ValidationError, person.validate)
|
||||
|
||||
Person.drop_collection()
|
||||
|
||||
def test_boolean_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to boolean fields.
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue