'Ensure that a GenericReferenceField properly dereferences items.'

def test_generic_reference(self):

    class Link(Document, ):
        title = StringField()
        meta = {'allow_inheritance': False}
    class Post(Document, ):
        title = StringField()
    class Bookmark(Document, ):
        bookmark_object = GenericReferenceField()
    Link.drop_collection()
    Post.drop_collection()
    Bookmark.drop_collection()
    link_1 = Link(title='Pitchfork')
    link_1.save()
    post_1 = Post(title='Behind    the    Scenes    of    the    Pavement    Reunion')
    post_1.save()
    bm = Bookmark(bookmark_object=post_1)
    bm.save()
    bm = Bookmark.objects(bookmark_object=post_1).first()
    self.assertEqual(bm.bookmark_object, post_1)
    self.assertTrue(isinstance(bm.bookmark_object, Post))
    bm.bookmark_object = link_1
    bm.save()
    bm = Bookmark.objects(bookmark_object=link_1).first()
    self.assertEqual(bm.bookmark_object, link_1)
    self.assertTrue(isinstance(bm.bookmark_object, Link))
