'Ensure that a validation result to_dict is available.'

def test_recursive_validation(self):

    class Author(EmbeddedDocument, ):
        name = StringField(required=True)
    class Comment(EmbeddedDocument, ):
        author = EmbeddedDocumentField(Author, required=True)
        content = StringField(required=True)
    class Post(Document, ):
        title = StringField(required=True)
        comments = ListField(EmbeddedDocumentField(Comment))
    bob = Author(name='Bob')
    post = Post(title='hello    world')
    post.comments.append(Comment(content='hello', author=bob))
    post.comments.append(Comment(author=bob))
    self.assertRaises(ValidationError, post.validate)
    try:
        post.validate()
    except ValidationError as error:
        self.assertTrue(hasattr(error, 'errors'))
        self.assertTrue(isinstance(error.errors, dict))
        self.assertTrue(('comments' in error.errors))
        self.assertTrue((1 in error.errors['comments']))
        self.assertTrue(isinstance(error.errors['comments'][1]['content'], ValidationError))
        error_dict = error.to_dict()
        self.assertTrue(isinstance(error_dict, dict))
        self.assertTrue(('comments' in error_dict))
        self.assertTrue((1 in error_dict['comments']))
        self.assertTrue(('content' in error_dict['comments'][1]))
        self.assertEqual(error_dict['comments'][1]['content'], u'Field    is    required')
    post.comments[1].content = 'here    we    go'
    post.validate()
