MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_try_next

Method test_try_next

test/test_change_stream.py:161–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

159
160 @no_type_check
161 def test_try_next(self):
162 # ChangeStreams only read majority committed data so use w:majority.
163 coll = self.watched_collection().with_options(write_concern=WriteConcern("majority"))
164 coll.drop()
165 coll.insert_one({})
166 self.addCleanup(coll.drop)
167 with self.change_stream(max_await_time_ms=250) as stream:
168 self.assertIsNone(stream.try_next()) # No changes initially.
169 coll.insert_one({}) # Generate a change.
170
171 # On sharded clusters, even majority-committed changes only show
172 # up once an event that sorts after it shows up on the other
173 # shard. So, we wait on try_next to eventually return changes.
174 def _wait_until():
175 return stream.try_next() is not None
176
177 wait_until(_wait_until, "get change from try_next")
178
179 @no_type_check
180 def test_try_next_runs_one_getmore(self):

Callers

nothing calls this directly

Calls 9

WriteConcernClass · 0.90
wait_untilFunction · 0.85
addCleanupMethod · 0.80
with_optionsMethod · 0.45
watched_collectionMethod · 0.45
dropMethod · 0.45
insert_oneMethod · 0.45
change_streamMethod · 0.45
try_nextMethod · 0.45

Tested by

no test coverage detected