'Ensure that a document reference field may be saved in the
database.'

def test_save_reference(self):

    class BlogPost(Document, ):
        meta = {'collection': 'blogpost_1'}
        content = StringField()
        author = ReferenceField(self.Person)
    BlogPost.drop_collection()
    author = self.Person(name='Test    User')
    author.save()
    post = BlogPost(content='Watched    some    TV    today...    how    exciting.')
    post.author = author
    post.save()
    post_obj = BlogPost.objects.first()
    self.assertTrue(isinstance(post_obj._data['author'], bson.DBRef))
    self.assertTrue(isinstance(post_obj.author, self.Person))
    self.assertEqual(post_obj.author.name, 'Test    User')
    post_obj.author.age = 25
    post_obj.author.save()
    author = list(self.Person.objects(name='Test    User'))[(-1)]
    self.assertEqual(author.age, 25)
