(self)
| 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({}) |
nothing calls this directly
no test coverage detected