MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_drop_index

Method test_drop_index

test/test_collection.py:337–367  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

335 db.test.create_index({"hello": 1}.items()) # type:ignore[arg-type]
336
337 def test_drop_index(self):
338 db = self.db
339 db.test.drop_indexes()
340 db.test.create_index("hello")
341 name = db.test.create_index("goodbye")
342
343 self.assertEqual(len(db.test.index_information()), 3)
344 self.assertEqual(name, "goodbye_1")
345 db.test.drop_index(name)
346
347 # Drop it again.
348 if client_context.version < Version(8, 3, -1):
349 with self.assertRaises(OperationFailure):
350 db.test.drop_index(name)
351 else:
352 db.test.drop_index(name)
353 self.assertEqual(len(db.test.index_information()), 2)
354 self.assertIn("hello_1", db.test.index_information())
355
356 db.test.drop_indexes()
357 db.test.create_index("hello")
358 name = db.test.create_index("goodbye")
359
360 self.assertEqual(len(db.test.index_information()), 3)
361 self.assertEqual(name, "goodbye_1")
362 db.test.drop_index([("goodbye", ASCENDING)])
363 self.assertEqual(len(db.test.index_information()), 2)
364 self.assertIn("hello_1", db.test.index_information())
365
366 with self.write_concern_collection() as coll:
367 coll.drop_index("hello_1")
368
369 @client_context.require_no_mongos
370 @client_context.require_test_commands

Callers

nothing calls this directly

Calls 6

VersionClass · 0.90
drop_indexesMethod · 0.45
create_indexMethod · 0.45
index_informationMethod · 0.45
drop_indexMethod · 0.45

Tested by

no test coverage detected