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

Method test_rewind

test/asynchronous/test_cursor.py:873–903  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

871 self.assertRaises(InvalidOperation, a.where, "this.x < 3")
872
873 async def test_rewind(self):
874 await self.db.test.insert_many([{"x": i} for i in range(1, 4)])
875
876 cursor = self.db.test.find().limit(2)
877
878 count = 0
879 async for _ in cursor:
880 count += 1
881 self.assertEqual(2, count)
882
883 count = 0
884 async for _ in cursor:
885 count += 1
886 self.assertEqual(0, count)
887
888 await cursor.rewind()
889 count = 0
890 async for _ in cursor:
891 count += 1
892 self.assertEqual(2, count)
893
894 await cursor.rewind()
895 count = 0
896 async for _ in cursor:
897 break
898 await cursor.rewind()
899 async for _ in cursor:
900 count += 1
901 self.assertEqual(2, count)
902
903 self.assertEqual(cursor, await cursor.rewind())
904
905 # oplog_reply, and snapshot are all deprecated.
906 @ignore_deprecations

Callers

nothing calls this directly

Calls 4

insert_manyMethod · 0.45
limitMethod · 0.45
findMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected