MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_drop_database

Method test_drop_database

test/test_client.py:1044–1065  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1042 self.assertCountEqual(db_names, cmd_names)
1043
1044 def test_drop_database(self):
1045 with self.assertRaises(TypeError):
1046 self.client.drop_database(5) # type: ignore[arg-type]
1047 with self.assertRaises(TypeError):
1048 self.client.drop_database(None) # type: ignore[arg-type]
1049
1050 self.client.pymongo_test.test.insert_one({"dummy": "object"})
1051 self.client.pymongo_test2.test.insert_one({"dummy": "object"})
1052 dbs = self.client.list_database_names()
1053 self.assertIn("pymongo_test", dbs)
1054 self.assertIn("pymongo_test2", dbs)
1055 self.client.drop_database("pymongo_test")
1056
1057 if client_context.is_rs:
1058 wc_client = self.rs_or_single_client(w=len(client_context.nodes) + 1)
1059 with self.assertRaises(WriteConcernError):
1060 wc_client.drop_database("pymongo_test2")
1061
1062 self.client.drop_database(self.client.pymongo_test2)
1063 dbs = self.client.list_database_names()
1064 self.assertNotIn("pymongo_test", dbs)
1065 self.assertNotIn("pymongo_test2", dbs)
1066
1067 def test_close(self):
1068 test_client = self.rs_or_single_client()

Callers

nothing calls this directly

Calls 4

rs_or_single_clientMethod · 0.80
drop_databaseMethod · 0.45
insert_oneMethod · 0.45
list_database_namesMethod · 0.45

Tested by

no test coverage detected