Updated validation error messages

refs hmarr/mongoengine#539
This commit is contained in:
Ross Lawley
2012-07-19 15:04:12 +01:00
parent d83e67c121
commit 1b17fb0ae7
4 changed files with 21 additions and 19 deletions

View File

@@ -3137,7 +3137,7 @@ class ValidatorErrorTest(unittest.TestCase):
self.assertEquals(error.to_dict()['1st']['2nd']['3rd']['4th'],
'Inception')
self.assertEquals(error.message, "root:\n1st.2nd.3rd.4th: Inception")
self.assertEquals(error.message, "root(2nd.3rd.4th.Inception: ['1st'])")
def test_model_validation(self):
@@ -3148,13 +3148,11 @@ class ValidatorErrorTest(unittest.TestCase):
try:
User().validate()
except ValidationError, e:
expected_error_message = """Errors encountered validating document:
username: Field is required ("username")
name: Field is required ("name")"""
expected_error_message = """ValidationError(Field is required: ['username', 'name'])"""
self.assertEquals(e.message, expected_error_message)
self.assertEquals(e.to_dict(), {
'username': 'Field is required ("username")',
'name': u'Field is required ("name")'})
'username': 'Field is required',
'name': 'Field is required'})
def test_spaces_in_keys(self):

View File

@@ -2122,7 +2122,7 @@ class FieldTest(unittest.TestCase):
self.assertTrue(1 in error_dict['comments'])
self.assertTrue('content' in error_dict['comments'][1])
self.assertEquals(error_dict['comments'][1]['content'],
u'Field is required ("content")')
'Field is required')
post.comments[1].content = 'here we go'
post.validate()