@@ -998,3 +998,52 @@ def test_post_processing_upload_503_error(
998998 assert any (
999999 "Upload failed with error" in str (call ) for call in mock_error .call_args_list
10001000 )
1001+
1002+
1003+ @mock .patch ("imap_processing.cli.filter_day_boundary_data" )
1004+ @mock .patch ("imap_processing.cli.swe_l1a" )
1005+ def test_post_processing_upload_unknown_error (
1006+ mock_swe_l1a ,
1007+ mock_filter ,
1008+ mock_instrument_dependencies ,
1009+ ):
1010+ """Test coverage for post processing when the upload fails with unknown error"""
1011+
1012+ mocks = mock_instrument_dependencies
1013+ mocks ["mock_download" ].return_value = "dependency0"
1014+ mocks ["mock_write_cdf" ].side_effect = [
1015+ "/path/to/imap_swe_l1a_test_20100105_v001.cdf"
1016+ ]
1017+ mocks [
1018+ "mock_write_cdf"
1019+ ].return_value = "/path/to/imap_swe_l1a_test_20100105_v001.cdf"
1020+ mocks ["mock_query" ].return_value = []
1021+
1022+ # Mocks an unknown error received from the upload API
1023+ mocks ["mock_upload" ].side_effect = RuntimeError ("Unexpected failure" )
1024+
1025+ test_ds = xr .Dataset ()
1026+ mock_swe_l1a .return_value = [test_ds ]
1027+ mock_filter .side_effect = lambda ds , _ : ds
1028+ input_collection = ProcessingInputCollection (
1029+ ScienceInput ("imap_swe_l0_raw_20100105_v001.pkts" ),
1030+ SPICEInput ("naif0012.tls" , "imap_sclk_0001.tsc" ),
1031+ )
1032+ mocks ["mock_pre_processing" ].return_value = input_collection
1033+
1034+ dependency_str = (
1035+ '[{"type": "science","files": ["imap_swe_l0_raw_20100105_v001.pkts"]}, '
1036+ '{"type": "spice", "files": ["naif0012.tls", "imap_sclk_0001.tsc"]}]'
1037+ )
1038+ instrument = Swe ("l1a" , "raw" , dependency_str , "20100105" , None , "v001" , True )
1039+
1040+ # Checks that the upload failed and logs an error and raises an exception
1041+ with mock .patch ("logging.Logger.error" ) as mock_error :
1042+ with pytest .raises (RuntimeError ):
1043+ instrument .process ()
1044+
1045+ # Checks the upload failure was logged
1046+ assert any (
1047+ "Upload failed unknown error" in str (call )
1048+ for call in mock_error .call_args_list
1049+ )
0 commit comments