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

Method test_skip

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

Source from the content-addressed store, hash-verified

722 self.assertEqual(101, curs._retrieved)
723
724 async def test_skip(self):
725 db = self.db
726
727 with self.assertRaises(TypeError):
728 db.test.find().skip(None) # type: ignore[arg-type]
729 with self.assertRaises(TypeError):
730 db.test.find().skip("hello") # type: ignore[arg-type]
731 with self.assertRaises(TypeError):
732 db.test.find().skip(5.5) # type: ignore[arg-type]
733 with self.assertRaises(ValueError):
734 db.test.find().skip(-5)
735 self.assertTrue((db.test.find()).skip(5))
736
737 await db.drop_collection("test")
738
739 await db.test.insert_many([{"x": i} for i in range(100)])
740
741 async for i in db.test.find():
742 self.assertEqual(i["x"], 0)
743 break
744
745 async for i in db.test.find().skip(20):
746 self.assertEqual(i["x"], 20)
747 break
748
749 async for i in db.test.find().skip(99):
750 self.assertEqual(i["x"], 99)
751 break
752
753 async for i in db.test.find().skip(1):
754 self.assertEqual(i["x"], 1)
755 break
756
757 async for i in db.test.find().skip(0):
758 self.assertEqual(i["x"], 0)
759 break
760
761 async for i in db.test.find().skip(0).skip(50).skip(10):
762 self.assertEqual(i["x"], 10)
763 break
764
765 async for _ in db.test.find().skip(1000):
766 self.fail()
767
768 a = db.test.find()
769 a.skip(10)
770 async for _ in a:
771 break
772 self.assertRaises(InvalidOperation, a.skip, 5)
773
774 async def test_sort(self):
775 db = self.db

Callers

nothing calls this directly

Calls 4

skipMethod · 0.45
findMethod · 0.45
drop_collectionMethod · 0.45
insert_manyMethod · 0.45

Tested by

no test coverage detected