'Ensure filters can be chained together.'

def test_filter_chaining(self):

    class Blog(Document, ):
        id = StringField(unique=True, primary_key=True)
    class BlogPost(Document, ):
        blog = ReferenceField(Blog)
        title = StringField()
        is_published = BooleanField()
        published_date = DateTimeField()
        @queryset_manager
        def published(doc_cls, queryset):
            return queryset(is_published=True)
    Blog.drop_collection()
    BlogPost.drop_collection()
    blog_1 = Blog(id='1')
    blog_2 = Blog(id='2')
    blog_3 = Blog(id='3')
    blog_1.save()
    blog_2.save()
    blog_3.save()
    BlogPost.objects.create(blog=blog_1, title='Blog    Post    #1', is_published=True, published_date=datetime.datetime(2010, 1, 5, 0, 0, 0))
    BlogPost.objects.create(blog=blog_2, title='Blog    Post    #2', is_published=True, published_date=datetime.datetime(2010, 1, 6, 0, 0, 0))
    BlogPost.objects.create(blog=blog_3, title='Blog    Post    #3', is_published=True, published_date=datetime.datetime(2010, 1, 7, 0, 0, 0))
    published_posts = BlogPost.published()
    published_posts = published_posts.filter(published_date__lt=datetime.datetime(2010, 1, 7, 0, 0, 0))
    self.assertEqual(published_posts.count(), 2)
    blog_posts = BlogPost.objects
    blog_posts = blog_posts.filter(blog__in=[blog_1, blog_2])
    blog_posts = blog_posts.filter(blog=blog_3)
    self.assertEqual(blog_posts.count(), 0)
    BlogPost.drop_collection()
    Blog.drop_collection()
