@@ -86,6 +86,15 @@ def mock_request_post_return(url, files, timeout):
8686 self .assertEqual (expected_match_url , match_url )
8787 self .assertEqual (expected_run_url , run_url )
8888
89+ @mock .patch ("scanpipe.pipes.matchcode.request_post" )
90+ def test_scanpipe_pipes_matchcode_send_project_json_to_matchcode_failed_request (
91+ self , mock_request_post
92+ ):
93+ mock_request_post .return_value = None
94+ with self .assertRaises (matchcode .MatchCodeIOException ) as context :
95+ matchcode .send_project_json_to_matchcode (self .project1 )
96+ self .assertEqual ("Invalid response from MatchCode.io" , str (context .exception ))
97+
8998 @mock .patch ("scanpipe.pipes.matchcode.request_get" )
9099 @mock .patch ("scanpipe.pipes.matchcode.is_available" )
91100 def test_scanpipe_pipes_matchcode_get_run_url_status (
@@ -168,7 +177,7 @@ def test_scanpipe_pipes_matchcode_poll_run_url_status(
168177 "log" : "failure message" ,
169178 },
170179 ]
171- with self .assertRaises (Exception ) as context :
180+ with self .assertRaises (matchcode . MatchCodeIOException ) as context :
172181 matchcode .poll_run_url_status (run_url , sleep = 0 )
173182 self .assertTrue ("failure message" in str (context .exception ))
174183
@@ -197,7 +206,7 @@ def test_scanpipe_pipes_matchcode_poll_run_url_status(
197206 "log" : "stop message" ,
198207 },
199208 ]
200- with self .assertRaises (Exception ) as context :
209+ with self .assertRaises (matchcode . MatchCodeIOException ) as context :
201210 matchcode .poll_run_url_status (run_url , sleep = 0 )
202211 self .assertTrue ("stop message" in str (context .exception ))
203212
@@ -226,7 +235,7 @@ def test_scanpipe_pipes_matchcode_poll_run_url_status(
226235 "log" : "stale message" ,
227236 },
228237 ]
229- with self .assertRaises (Exception ) as context :
238+ with self .assertRaises (matchcode . MatchCodeIOException ) as context :
230239 matchcode .poll_run_url_status (run_url , sleep = 0 )
231240 self .assertTrue ("stale message" in str (context .exception ))
232241
0 commit comments