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

Method test_clone

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

Source from the content-addressed store, hash-verified

905 # oplog_reply, and snapshot are all deprecated.
906 @ignore_deprecations
907 async def test_clone(self):
908 await self.db.test.insert_many([{"x": i} for i in range(1, 4)])
909
910 cursor = self.db.test.find().limit(2)
911
912 count = 0
913 async for _ in cursor:
914 count += 1
915 self.assertEqual(2, count)
916
917 count = 0
918 async for _ in cursor:
919 count += 1
920 self.assertEqual(0, count)
921
922 cursor = cursor.clone()
923 cursor2 = cursor.clone()
924 count = 0
925 async for _ in cursor:
926 count += 1
927 self.assertEqual(2, count)
928 async for _ in cursor2:
929 count += 1
930 self.assertEqual(4, count)
931
932 await cursor.rewind()
933 count = 0
934 async for _ in cursor:
935 break
936 cursor = cursor.clone()
937 async for _ in cursor:
938 count += 1
939 self.assertEqual(2, count)
940
941 self.assertNotEqual(cursor, cursor.clone())
942
943 # Just test attributes
944 cursor = (
945 self.db.test.find(
946 {"x": re.compile("^hello.*")},
947 projection={"_id": False},
948 skip=1,
949 no_cursor_timeout=True,
950 cursor_type=CursorType.TAILABLE_AWAIT,
951 sort=[("x", 1)],
952 allow_partial_results=True,
953 oplog_replay=True,
954 batch_size=123,
955 collation={"locale": "en_US"},
956 hint=[("_id", 1)],
957 max_scan=100,
958 max_time_ms=1000,
959 return_key=True,
960 show_record_id=True,
961 snapshot=True,
962 allow_disk_use=True,
963 )
964 ).limit(2)

Callers

nothing calls this directly

Calls 12

copyMethod · 0.80
keysMethod · 0.80
insert_manyMethod · 0.45
limitMethod · 0.45
findMethod · 0.45
cloneMethod · 0.45
rewindMethod · 0.45
maxMethod · 0.45
minMethod · 0.45
add_optionMethod · 0.45
commentMethod · 0.45
hintMethod · 0.45

Tested by

no test coverage detected