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

Method test_aggregate_error

test/test_session.py:675–691  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

673 self._test_ops(client, (explicit_close, [], {}))
674
675 def test_aggregate_error(self):
676 listener = self.listener
677 client = self.client
678 coll = client.pymongo_test.collection
679 # 3.6.0 mongos only validates the aggregate pipeline when the
680 # database exists.
681 coll.insert_one({})
682 listener.reset()
683
684 with self.assertRaises(OperationFailure):
685 coll.aggregate([{"$badOperation": {"bar": 1}}])
686
687 event = listener.first_command_started()
688 self.assertEqual(event.command_name, "aggregate")
689 lsid = event.command["lsid"]
690 # Session was returned to pool despite error.
691 self.assertIn(lsid, session_ids(client))
692
693 def _test_cursor_helper(self, create_cursor, close_cursor):
694 coll = self.client.pymongo_test.collection

Callers

nothing calls this directly

Calls 5

session_idsFunction · 0.70
insert_oneMethod · 0.45
resetMethod · 0.45
aggregateMethod · 0.45
first_command_startedMethod · 0.45

Tested by

no test coverage detected