'Ensure default ordering is applied and can be overridden.'

def test_ordering(self):

    class BlogPost(Document, ):
        title = StringField()
        published_date = DateTimeField()
        meta = {'ordering': ['-published_date']}
    BlogPost.drop_collection()
    blog_post_1 = BlogPost.objects.create(title='Blog    Post    #1', published_date=datetime.datetime(2010, 1, 5, 0, 0, 0))
    blog_post_2 = BlogPost.objects.create(title='Blog    Post    #2', published_date=datetime.datetime(2010, 1, 6, 0, 0, 0))
    blog_post_3 = BlogPost.objects.create(title='Blog    Post    #3', published_date=datetime.datetime(2010, 1, 7, 0, 0, 0))
    expected = [blog_post_3, blog_post_2, blog_post_1]
    self.assertSequence(BlogPost.objects.all(), expected)
    qs = BlogPost.objects.order_by('+published_date')
    expected = [blog_post_1, blog_post_2, blog_post_3]
    self.assertSequence(qs, expected)
