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

Method test_comment

test/asynchronous/test_cursor.py:1248–1275  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1246
1247 @async_client_context.require_no_mongos
1248 async def test_comment(self):
1249 await self.client.drop_database(self.db)
1250 await self.db.command("profile", 2) # Profile ALL commands.
1251 try:
1252 await self.db.test.find().comment("foo").to_list()
1253 count = await self.db.system.profile.count_documents(
1254 {"ns": "pymongo_test.test", "op": "query", "command.comment": "foo"}
1255 )
1256 self.assertEqual(count, 1)
1257
1258 await self.db.test.find().comment("foo").distinct("type")
1259 count = await self.db.system.profile.count_documents(
1260 {
1261 "ns": "pymongo_test.test",
1262 "op": "command",
1263 "command.distinct": "test",
1264 "command.comment": "foo",
1265 }
1266 )
1267 self.assertEqual(count, 1)
1268 finally:
1269 await self.db.command("profile", 0) # Turn off profiling.
1270 await self.db.system.profile.drop()
1271
1272 await self.db.test.insert_many([{}, {}])
1273 cursor = self.db.test.find()
1274 await anext(cursor)
1275 self.assertRaises(InvalidOperation, cursor.comment, "hello")
1276
1277 async def test_alive(self):
1278 await self.db.test.delete_many({})

Callers

nothing calls this directly

Calls 10

anextFunction · 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