'Ensure we load embedded document data correctly.'

def test_db_embedded_doc_field_load(self):

    class Rank(EmbeddedDocument, ):
        title = StringField(required=True)
    class Person(Document, ):
        name = StringField(required=True)
        rank_ = EmbeddedDocumentField(Rank, required=False, db_field='rank')
        @property
        def rank(self):
            if (self.rank_ is None):
                return 'Private'
            return self.rank_.title
    Person.drop_collection()
    Person(name='Jack', rank_=Rank(title='Corporal')).save()
    Person(name='Fred').save()
    self.assertEqual(Person.objects.get(name='Jack').rank, 'Corporal')
    self.assertEqual(Person.objects.get(name='Fred').rank, 'Private')
