(self)
| 380 | |
| 381 | # https://github.com/mongodb/specifications/blob/master/source/crud/tests/README.md#14-explain-helpers-allow-users-to-specify-maxtimems |
| 382 | async def test_explain_csot(self): |
| 383 | # Create a MongoClient with command monitoring enabled (referred to as client). |
| 384 | listener = AllowListEventListener("explain") |
| 385 | client = await self.async_rs_or_single_client(event_listeners=[listener]) |
| 386 | |
| 387 | # Create a collection, referred to as collection, with the namespace explain-test.collection. |
| 388 | # Workaround for SERVER-108463 |
| 389 | names = await client["explain-test"].list_collection_names() |
| 390 | if "collection" not in names: |
| 391 | collection = await client["explain-test"].create_collection("collection") |
| 392 | else: |
| 393 | collection = client["explain-test"]["collection"] |
| 394 | |
| 395 | # Run an explained find on collection. The find will have the query predicate { name: 'john doe' }. Specify a maxTimeMS value of 2000ms for the explain. |
| 396 | with pymongo.timeout(2.0): |
| 397 | self.assertTrue(await collection.find({"name": "john doe"}).explain()) |
| 398 | |
| 399 | # Obtain the command started event for the explain. Confirm that the top-level explain command should has a maxTimeMS value of 2000. |
| 400 | started = listener.started_events |
| 401 | self.assertEqual(len(started), 1) |
| 402 | assert 1500 < started[0].command["maxTimeMS"] <= 2000 |
| 403 | |
| 404 | async def test_hint(self): |
| 405 | db = self.db |
nothing calls this directly
no test coverage detected