<s> import unittest <EOL> from mongoengine import Document , connect <EOL> from mongoengine . connection import get_db <EOL> from mongoengine . fields import StringField <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> class ConvertToNewInheritanceModel ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> connect ( db = '<STR_LIT>' ) <EOL> self . db = get_db ( ) <EOL> def tearDown ( self ) : <EOL> for collection in self . db . collection_names ( ) : <EOL> if '<STR_LIT>' in collection : <EOL> continue <EOL> self . db . drop_collection ( collection ) <EOL> def test_how_to_convert_to_the_new_inheritance_model ( self ) : <EOL> """<STR_LIT>""" <EOL> class Animal ( Document ) : <EOL> name = StringField ( ) <EOL> meta = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ '<STR_LIT:name>' ] <EOL> } <EOL> collection = Animal . _get_collection ( ) <EOL> collection . update ( { } , { "<STR_LIT>" : { "<STR_LIT>" : <NUM_LIT:1> } } , multi = True ) <EOL> count = collection . find ( { '<STR_LIT>' : { "<STR_LIT>" : True } } ) . count ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , count ) <EOL> info = collection . index_information ( ) <EOL> indexes_to_drop = [ key for key , value in info . iteritems ( ) <EOL> if '<STR_LIT>' in dict ( value [ '<STR_LIT:key>' ] ) ] <EOL> for index in indexes_to_drop : <EOL> collection . drop_index ( index ) <EOL> Animal . ensure_indexes ( ) </s>
