Fix IntField assignment unit tests
This commit is contained in:
parent
069aedabc1
commit
2a93a69085
3 changed files with 6 additions and 13 deletions
|
|
@ -20,6 +20,7 @@ Differences between Mongomallard and Mongoengine
|
|||
* `Document.save()` supports `full=True` keyword argument to force saving all model fields.
|
||||
* `_get_changed_fields()` / `_changed_fields` returns a set
|
||||
* Simplified `EmailField` email regex to be more compatible
|
||||
* Assigning invalid types (e.g. an invalid string to `IntField`) raises immediately a `ValueError`
|
||||
|
||||
Untested / not implemented yet:
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -134,13 +134,8 @@ class ValidatorErrorTest(unittest.TestCase):
|
|||
self.assertTrue('e' in keys)
|
||||
self.assertTrue('id' in keys)
|
||||
|
||||
doc.e.val = "OK"
|
||||
try:
|
||||
doc.save()
|
||||
except ValidationError, e:
|
||||
self.assertTrue("Doc:test" in e.message)
|
||||
self.assertEqual(e.to_dict(), {
|
||||
"e": {'val': 'OK could not be converted to int'}})
|
||||
with self.assertRaises(ValueError):
|
||||
doc.e.val = "OK"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -342,8 +342,8 @@ class FieldTest(unittest.TestCase):
|
|||
self.assertRaises(ValidationError, person.validate)
|
||||
person.age = 120
|
||||
self.assertRaises(ValidationError, person.validate)
|
||||
person.age = 'ten'
|
||||
self.assertRaises(ValidationError, person.validate)
|
||||
with self.assertRaises(ValueError):
|
||||
person.age = 'ten'
|
||||
|
||||
def test_float_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to float fields.
|
||||
|
|
@ -871,11 +871,8 @@ class FieldTest(unittest.TestCase):
|
|||
e.mapping = [1]
|
||||
e.save()
|
||||
|
||||
def create_invalid_mapping():
|
||||
with self.assertRaises(ValueError):
|
||||
e.mapping = ["abc"]
|
||||
e.save()
|
||||
|
||||
self.assertRaises(ValidationError, create_invalid_mapping)
|
||||
|
||||
Simple.drop_collection()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue