@@ -839,6 +839,58 @@ def test_get_product():
839839 remove_temp_dir ()
840840
841841
842+ @patch .object (TapPlus , 'load_data' )
843+ def test_get_product_with_list_of_filenames (mock_load_data , tmp_path_factory ):
844+ """
845+ Test that get_product accepts a list for file_name and converts it into
846+ a comma-separated string, while ensuring a real output file exists so
847+ __extract_file doesn't fail.
848+ """
849+
850+ # Set up the enviornment
851+ conn_handler = DummyConnHandler ()
852+ tap_plus = TapPlus (url = "http://test:1111/tap" , data_context = 'data' , client_id = 'ASTROQUERY' ,
853+ connhandler = conn_handler )
854+
855+ responseLaunchJob = DummyResponse (200 )
856+ responseLaunchJob .set_data (method = 'POST' , context = None , body = '' , headers = None )
857+ conn_handler .set_default_response (responseLaunchJob )
858+
859+ tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , show_server_messages = False )
860+
861+ # Mock: create the file
862+ def _fake_load_data (* args , ** kwargs ):
863+ output_file = kwargs .get ("output_file" )
864+ # Create a dummy fits and directory
865+ of = Path (output_file )
866+ of .parent .mkdir (parents = True , exist_ok = True )
867+ of .write_bytes (b"SIMPLE = T\n END\n " )
868+ return None
869+
870+ mock_load_data .side_effect = _fake_load_data
871+
872+ # Input a as file names list
873+ filenames = ["file1.fits" , "file2.fits" , "file3.fits" , "file4.fits" ]
874+
875+ # Force an output name with .fits so that the extractor treats it as 1 file
876+ out_dir = tmp_path_factory .mktemp ("euclid_tmp" )
877+ output_file = str (out_dir / "dummy.fits" )
878+
879+ result = tap .get_product (file_name = filenames , output_file = output_file )
880+
881+ # Must return a list of files (at least the one we created)
882+ assert result is not None
883+ assert isinstance (result , list )
884+ assert len (result ) >= 1
885+ assert result [0 ].endswith (".fits" )
886+
887+ # Verify that FILE_NAME is correct
888+ kwargs = mock_load_data .call_args .kwargs
889+ params_dict = kwargs .get ("params_dict" )
890+ assert params_dict ["FILE_NAME" ] == "file1.fits,file2.fits,file3.fits,file4.fits"
891+ assert params_dict ["RETRIEVAL_TYPE" ] == "FILE"
892+
893+
842894def test_get_product_exceptions ():
843895 conn_handler = DummyConnHandler ()
844896 tap_plus = TapPlus (url = "http://test:1111/tap" , data_context = 'data' , client_id = 'ASTROQUERY' ,
0 commit comments