'Ensure that the indexes are properly created and that
compare_indexes identifies the missing/extra indexes'

def test_compare_indexes(self):

    class BlogPost(Document, ):
        author = StringField()
        title = StringField()
        description = StringField()
        tags = StringField()
        meta = {'indexes': [('author', 'title')]}
    BlogPost.drop_collection()
    BlogPost.ensure_indexes()
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': []})
    BlogPost.ensure_index(['author', 'description'])
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': [[('author', 1), ('description', 1)]]})
    BlogPost._get_collection().drop_index('author_1_description_1')
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': []})
    BlogPost._get_collection().drop_index('author_1_title_1')
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [[('author', 1), ('title', 1)]], 'extra': []})
