@@ -199,19 +199,25 @@ def test_missions_get_product_list_async(self):
199199
200200 # Table as input
201201 responses = MastMissions .get_product_list_async (datasets [:3 ])
202- assert isinstance (responses , Response )
202+ assert isinstance (responses , list )
203203
204204 # Row as input
205205 responses = MastMissions .get_product_list_async (datasets [0 ])
206- assert isinstance (responses , Response )
206+ assert isinstance (responses , list )
207207
208208 # String as input
209209 responses = MastMissions .get_product_list_async (datasets [0 ]['sci_data_set_name' ])
210- assert isinstance (responses , Response )
210+ assert isinstance (responses , list )
211211
212212 # Column as input
213213 responses = MastMissions .get_product_list_async (datasets [:3 ]['sci_data_set_name' ])
214- assert isinstance (responses , Response )
214+ assert isinstance (responses , list )
215+
216+ # Batching
217+ responses = MastMissions .get_product_list_async (datasets [:4 ], batch_size = 2 )
218+ assert isinstance (responses , list )
219+ assert len (responses ) == 2
220+ assert isinstance (responses [0 ], Response )
215221
216222 # Unsupported data type for datasets
217223 with pytest .raises (TypeError ) as err_type :
@@ -248,14 +254,13 @@ def test_missions_get_product_list(self, capsys):
248254 assert isinstance (result , Table )
249255 assert (result ['dataset' ] == 'IBKH03020' ).all ()
250256
251- # Test batching by creating a list of 1001 different strings
252- # This won't return any results, but will test the batching
253- dataset_list = [f'{ i } ' for i in range (1001 )]
254- result = MastMissions .get_product_list (dataset_list )
257+ # Test batching
258+ result_batch = MastMissions .get_product_list (datasets [:2 ], batch_size = 1 )
255259 out , _ = capsys .readouterr ()
256- assert isinstance (result , Table )
257- assert len (result ) == 0
258- assert 'Fetching products for 1001 unique datasets in 2 batches' in out
260+ assert isinstance (result_batch , Table )
261+ assert len (result_batch ) == len (result_table )
262+ assert set (result_batch ['filename' ]) == set (result_table ['filename' ])
263+ assert 'Fetching products for 2 unique datasets in 2 batches' in out
259264
260265 def test_missions_get_unique_product_list (self , caplog ):
261266 # Check that no rows are filtered out when all products are unique
@@ -593,7 +598,11 @@ def test_observations_get_product_list_async(self):
593598 responses = Observations .get_product_list_async (observations [0 :4 ])
594599 assert isinstance (responses , list )
595600
596- def test_observations_get_product_list (self ):
601+ # Batching
602+ responses = Observations .get_product_list_async (observations [0 :4 ], batch_size = 2 )
603+ assert isinstance (responses , list )
604+
605+ def test_observations_get_product_list (self , capsys ):
597606 observations = Observations .query_criteria (objectname = 'M8' , obs_collection = ['K2' , 'IUE' ])
598607 test_obs_id = str (observations [0 ]['obsid' ])
599608 mult_obs_ids = str (observations [0 ]['obsid' ]) + ',' + str (observations [1 ]['obsid' ])
@@ -626,6 +635,14 @@ def test_observations_get_product_list(self):
626635 assert len (obs_collection ) == 1
627636 assert obs_collection [0 ] == 'IUE'
628637
638+ # Test batching
639+ result_batch = Observations .get_product_list (observations [:2 ], batch_size = 1 )
640+ out , _ = capsys .readouterr ()
641+ assert isinstance (result_batch , Table )
642+ assert len (result_batch ) == len (result1 )
643+ assert set (result_batch ['productFilename' ]) == set (filenames1 )
644+ assert 'Fetching products for 2 unique observations in 2 batches' in out
645+
629646 def test_observations_get_product_list_tess_tica (self , caplog ):
630647 # Get observations and products with both TESS and TICA FFIs
631648 obs = Observations .query_criteria (target_name = ['TESS FFI' , 'TICA FFI' , '429031146' ])
0 commit comments