'Ensure a DynamicField can handle another document\'s dump.'

def test_dynamicfield_dump_document(self):

    class Doc(Document, ):
        field = DynamicField()
    class ToEmbed(Document, ):
        id = IntField(primary_key=True, default=1)
        recursive = DynamicField()
    class ToEmbedParent(Document, ):
        id = IntField(primary_key=True, default=1)
        recursive = DynamicField()
        meta = {'allow_inheritance': True}
    class ToEmbedChild(ToEmbedParent, ):
        pass
    to_embed_recursive = ToEmbed(id=1).save()
    to_embed = ToEmbed(id=2, recursive=to_embed_recursive).save()
    doc = Doc(field=to_embed)
    doc.save()
    assert isinstance(doc.field, ToEmbed)
    assert (doc.field == to_embed)
    to_embed_recursive = ToEmbedChild(id=1).save()
    to_embed_child = ToEmbedChild(id=2, recursive=to_embed_recursive).save()
    doc = Doc(field=to_embed_child)
    doc.save()
    assert isinstance(doc.field, ToEmbedChild)
    assert (doc.field == to_embed_child)
