'Ensure that the indexes are properly created and that
compare_indexes identifies the missing/extra indexes for subclassed
documents (_cls included)'

def test_compare_indexes_inheritance(self):

    class BlogPost(Document, ):
        author = StringField()
        title = StringField()
        description = StringField()
        meta = {'allow_inheritance': True}
    class BlogPostWithTags(BlogPost, ):
        tags = StringField()
        tag_list = ListField(StringField())
        meta = {'indexes': [('author', 'tags')]}
    BlogPost.drop_collection()
    BlogPost.ensure_indexes()
    BlogPostWithTags.ensure_indexes()
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': []})
    BlogPostWithTags.ensure_index(['author', 'tag_list'])
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': [[('_cls', 1), ('author', 1), ('tag_list', 1)]]})
    BlogPostWithTags._get_collection().drop_index('_cls_1_author_1_tag_list_1')
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [], 'extra': []})
    BlogPostWithTags._get_collection().drop_index('_cls_1_author_1_tags_1')
    self.assertEqual(BlogPost.compare_indexes(), {'missing': [[('_cls', 1), ('author', 1), ('tags', 1)]], 'extra': []})
