'Ensure that custom QuerySetManager instances work as expected.'

def test_custom_manager(self):

    class BlogPost(Document, ):
        tags = ListField(StringField())
        deleted = BooleanField(default=False)
        date = DateTimeField(default=datetime.datetime.now)
        @queryset_manager
        def objects(cls, qryset):
            opts = {'deleted': False}
            return qryset(**opts)
        @queryset_manager
        def music_posts(doc_cls, queryset, deleted=False):
            return queryset(tags='music', deleted=deleted).order_by('date')
    BlogPost.drop_collection()
    post1 = BlogPost(tags=['music', 'film']).save()
    post2 = BlogPost(tags=['music']).save()
    post3 = BlogPost(tags=['film', 'actors']).save()
    post4 = BlogPost(tags=['film', 'actors', 'music'], deleted=True).save()
    self.assertEqual([p.id for p in BlogPost.objects()], [post1.id, post2.id, post3.id])
    self.assertEqual([p.id for p in BlogPost.music_posts()], [post1.id, post2.id])
    self.assertEqual([p.id for p in BlogPost.music_posts(True)], [post4.id])
    BlogPost.drop_collection()
