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

Method test_reads

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

Source from the content-addressed store, hash-verified

1018
1019 @client_context.require_no_standalone
1020 def test_reads(self):
1021 # Make sure the collection exists.
1022 self.client.pymongo_test.test.insert_one({})
1023
1024 def aggregate(coll, session):
1025 return (coll.aggregate([], session=session)).to_list()
1026
1027 def aggregate_raw(coll, session):
1028 return (coll.aggregate_raw_batches([], session=session)).to_list()
1029
1030 def find_raw(coll, session):
1031 return coll.find_raw_batches({}, session=session).to_list()
1032
1033 self._test_reads(aggregate)
1034 self._test_reads(lambda coll, session: coll.find({}, session=session).to_list())
1035 self._test_reads(lambda coll, session: coll.find_one({}, session=session))
1036 self._test_reads(lambda coll, session: coll.count_documents({}, session=session))
1037 self._test_reads(lambda coll, session: coll.distinct("foo", session=session))
1038 self._test_reads(aggregate_raw)
1039 self._test_reads(find_raw)
1040
1041 with self.assertRaises(ConfigurationError):
1042 self._test_reads(lambda coll, session: coll.estimated_document_count(session=session))
1043
1044 def _test_writes(self, op):
1045 coll = self.client.pymongo_test.test

Callers

nothing calls this directly

Calls 8

_test_readsMethod · 0.95
insert_oneMethod · 0.45
to_listMethod · 0.45
findMethod · 0.45
find_oneMethod · 0.45
count_documentsMethod · 0.45
distinctMethod · 0.45

Tested by

no test coverage detected