'Ensure embedded dynamic documents may be validated'

def test_complex_embedded_document_validation(self):

    class Embedded(DynamicEmbeddedDocument, ):
        content = URLField()
    class Doc(DynamicDocument, ):
        pass
    Doc.drop_collection()
    doc = Doc()
    embedded_doc_1 = Embedded(content='http://mongoengine.org')
    embedded_doc_1.validate()
    embedded_doc_2 = Embedded(content='this    is    not    a    url')
    self.assertRaises(ValidationError, embedded_doc_2.validate)
    doc.embedded_field_1 = embedded_doc_1
    doc.embedded_field_2 = embedded_doc_2
    self.assertRaises(ValidationError, doc.validate)
