@@ -1380,6 +1380,43 @@ async def test_getMore_does_not_send_readPreference(self):
13801380 self .assertEqual ("getMore" , started [1 ].command_name )
13811381 self .assertNotIn ("$readPreference" , started [1 ].command )
13821382
1383+ @async_client_context .require_replica_set
1384+ async def test_to_list_tailable (self ):
1385+ oplog = self .client .local .oplog .rs
1386+ last = await oplog .find ().sort ("$natural" , pymongo .DESCENDING ).limit (- 1 ).next ()
1387+ ts = last ["ts" ]
1388+
1389+ c = oplog .find (
1390+ {"ts" : {"$gte" : ts }}, cursor_type = pymongo .CursorType .TAILABLE_AWAIT , oplog_replay = True
1391+ )
1392+
1393+ docs = await c .to_list ()
1394+
1395+ self .assertGreaterEqual (len (docs ), 1 )
1396+
1397+ async def test_to_list_empty (self ):
1398+ c = self .db .does_not_exist .find ()
1399+
1400+ docs = await c .to_list ()
1401+
1402+ self .assertEqual ([], docs )
1403+
1404+ @async_client_context .require_replica_set
1405+ async def test_command_cursor_to_list (self ):
1406+ c = await self .db .test .aggregate ([{"$changeStream" : {}}])
1407+
1408+ docs = await c .to_list ()
1409+
1410+ self .assertGreaterEqual (len (docs ), 0 )
1411+
1412+ @async_client_context .require_replica_set
1413+ async def test_command_cursor_to_list_empty (self ):
1414+ c = await self .db .does_not_exist .aggregate ([{"$changeStream" : {}}])
1415+
1416+ docs = await c .to_list ()
1417+
1418+ self .assertEqual ([], docs )
1419+
13831420
13841421class TestRawBatchCursor (AsyncIntegrationTest ):
13851422 async def test_find_raw (self ):
0 commit comments