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

Method test_comment

test/test_cursor.py:1239–1266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1237
1238 @client_context.require_no_mongos
1239 def test_comment(self):
1240 self.client.drop_database(self.db)
1241 self.db.command("profile", 2) # Profile ALL commands.
1242 try:
1243 self.db.test.find().comment("foo").to_list()
1244 count = self.db.system.profile.count_documents(
1245 {"ns": "pymongo_test.test", "op": "query", "command.comment": "foo"}
1246 )
1247 self.assertEqual(count, 1)
1248
1249 self.db.test.find().comment("foo").distinct("type")
1250 count = self.db.system.profile.count_documents(
1251 {
1252 "ns": "pymongo_test.test",
1253 "op": "command",
1254 "command.distinct": "test",
1255 "command.comment": "foo",
1256 }
1257 )
1258 self.assertEqual(count, 1)
1259 finally:
1260 self.db.command("profile", 0) # Turn off profiling.
1261 self.db.system.profile.drop()
1262
1263 self.db.test.insert_many([{}, {}])
1264 cursor = self.db.test.find()
1265 next(cursor)
1266 self.assertRaises(InvalidOperation, cursor.comment, "hello")
1267
1268 def test_alive(self):
1269 self.db.test.delete_many({})

Callers

nothing calls this directly

Calls 10

nextFunction · 0.90
drop_databaseMethod · 0.45
commandMethod · 0.45
to_listMethod · 0.45
commentMethod · 0.45
findMethod · 0.45
count_documentsMethod · 0.45
distinctMethod · 0.45
dropMethod · 0.45
insert_manyMethod · 0.45

Tested by

no test coverage detected