@@ -787,6 +787,42 @@ async def _databaseOperation_createCommandCursor(self, target, **kwargs):
787787
788788 return cursor
789789
790+ async def _collectionOperation_assertIndexExists (self , target , ** kwargs ):
791+ collection = self .client [kwargs ["database_name" ]][kwargs ["collection_name" ]]
792+ index_names = [idx ["name" ] async for idx in await collection .list_indexes ()]
793+ self .assertIn (kwargs ["index_name" ], index_names )
794+
795+ async def _collectionOperation_assertIndexNotExists (self , target , ** kwargs ):
796+ collection = self .client [kwargs ["database_name" ]][kwargs ["collection_name" ]]
797+ async for index in await collection .list_indexes ():
798+ self .assertNotEqual (kwargs ["indexName" ], index ["name" ])
799+
800+ async def _collectionOperation_assertCollectionExists (self , target , ** kwargs ):
801+ database_name = kwargs ["database_name" ]
802+ collection_name = kwargs ["collection_name" ]
803+ collection_name_list = list (
804+ await self .client .get_database (database_name ).list_collection_names ()
805+ )
806+ self .assertIn (collection_name , collection_name_list )
807+
808+ async def _databaseOperation_assertIndexExists (self , target , ** kwargs ):
809+ collection = self .client [kwargs ["database_name" ]][kwargs ["collection_name" ]]
810+ index_names = [idx ["name" ] async for idx in await collection .list_indexes ()]
811+ self .assertIn (kwargs ["index_name" ], index_names )
812+
813+ async def _databaseOperation_assertIndexNotExists (self , target , ** kwargs ):
814+ collection = self .client [kwargs ["database_name" ]][kwargs ["collection_name" ]]
815+ async for index in await collection .list_indexes ():
816+ self .assertNotEqual (kwargs ["indexName" ], index ["name" ])
817+
818+ async def _databaseOperation_assertCollectionExists (self , target , ** kwargs ):
819+ database_name = kwargs ["database_name" ]
820+ collection_name = kwargs ["collection_name" ]
821+ collection_name_list = list (
822+ await self .client .get_database (database_name ).list_collection_names ()
823+ )
824+ self .assertIn (collection_name , collection_name_list )
825+
790826 async def kill_all_sessions (self ):
791827 if getattr (self , "client" , None ) is None :
792828 return
0 commit comments