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

Method test_index_info

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

Source from the content-addressed store, hash-verified

418 self.assertEqual(len(indexes), 0)
419
420 def test_index_info(self):
421 db = self.db
422 db.test.drop()
423 db.test.insert_one({}) # create collection
424 self.assertEqual(len(db.test.index_information()), 1)
425 self.assertIn("_id_", db.test.index_information())
426
427 db.test.create_index("hello")
428 self.assertEqual(len(db.test.index_information()), 2)
429 self.assertEqual((db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)])
430
431 db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True)
432 self.assertEqual((db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)])
433 self.assertEqual(len(db.test.index_information()), 3)
434 self.assertEqual(
435 [("hello", DESCENDING), ("world", ASCENDING)],
436 (db.test.index_information())["hello_-1_world_1"]["key"],
437 )
438 self.assertEqual(True, (db.test.index_information())["hello_-1_world_1"]["unique"])
439
440 def test_index_geo2d(self):
441 db = self.db

Callers

nothing calls this directly

Calls 4

dropMethod · 0.45
insert_oneMethod · 0.45
index_informationMethod · 0.45
create_indexMethod · 0.45

Tested by

no test coverage detected