@@ -216,6 +216,37 @@ def test_download_release_attachment(self):
216216 os .remove (filename )
217217 os .removedirs (tmpdir )
218218
219+ @responses .activate
220+ def test_download_release_attachment_404 (self ):
221+ lib = SW360 (self .MYURL , self .MYTOKEN , False )
222+ lib .force_no_session = True
223+ self ._add_login_response ()
224+ actual = lib .login_api ()
225+ self .assertTrue (actual )
226+
227+ url = self .MYURL + "resource/api/releases/1234/attachments/5678"
228+ responses .add (
229+ method = responses .GET ,
230+ url = url ,
231+ body = 'xxxx' ,
232+ status = 404 ,
233+ content_type = "application/text" ,
234+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
235+ )
236+
237+ tmpdir = tempfile .mkdtemp ()
238+ filename = os .path .join (tmpdir , "test_attachment.txt" )
239+ if os .path .exists (filename ):
240+ os .remove (filename )
241+
242+ self .assertFalse (os .path .exists (filename ))
243+ with self .assertRaises (SW360Error ) as context :
244+ lib .download_release_attachment (filename , "1234" , "5678" )
245+ self .assertFalse (os .path .exists (filename ))
246+ self .assertEqual (context .exception .url , url )
247+ self .assertEqual (context .exception .response .status_code , 404 )
248+ os .removedirs (tmpdir )
249+
219250 @responses .activate
220251 def test_download_project_attachment (self ):
221252 lib = SW360 (self .MYURL , self .MYTOKEN , False )
0 commit comments