From f45612a730fdcd13defc459860eb6038f994f3b6 Mon Sep 17 00:00:00 2001 From: RAJVEER42 Date: Wed, 8 Jul 2026 12:41:38 +0530 Subject: [PATCH] test(uploads): add mocked error-path tests for delete_upload Refs #200. delete_upload had no mocked error test, unlike the other upload endpoints. Adds mocked 403 (AuthorizationError) and 500 (FossologyApiError) tests so its error-path coverage is consistent with the rest of the module. Signed-off-by: RAJVEER42 --- tests/test_uploads.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_uploads.py b/tests/test_uploads.py index 7d57d67..87e5a74 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -549,6 +549,30 @@ def test_delete_if_unknown_upload_raises_error(foss: Fossology, fake_hash: dict) foss.delete_upload(upload) +@responses.activate +def test_delete_upload_unauthorized(foss_server: str, foss: Fossology, upload: Upload): + responses.add( + responses.DELETE, + f"{foss_server}/api/v1/uploads/{upload.id}", + status=403, + ) + with pytest.raises(AuthorizationError) as excinfo: + foss.delete_upload(upload) + assert f"Not authorized to delete upload {upload.id}" in str(excinfo.value) + + +@responses.activate +def test_delete_upload_error(foss_server: str, foss: Fossology, upload: Upload): + responses.add( + responses.DELETE, + f"{foss_server}/api/v1/uploads/{upload.id}", + status=500, + ) + with pytest.raises(FossologyApiError) as excinfo: + foss.delete_upload(upload) + assert f"Unable to delete upload {upload.id}" in str(excinfo.value) + + def test_paginated_list_uploads(foss: Fossology, upload: Upload, test_file_path: str): # Add a second upload second_upload = foss.upload_file(