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