Skip to content

Commit

Permalink
fix(exceptions): instantiate the inherited exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
deveaud-m committed Feb 14, 2024
1 parent 6211083 commit 5de8aec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions fossology/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, description, response=None):
self.message = f"{description}: {message} ({response.status_code})"
else:
self.message = description
super().__init__(self.message)


class AuthorizationError(Error):
Expand All @@ -33,6 +34,7 @@ def __init__(self, description, response):
except JSONDecodeError:
message = response.text
self.message = f"{description}: {message} ({response.status_code})"
super().__init__(self.message)


class FossologyApiError(Error):
Expand All @@ -44,10 +46,12 @@ def __init__(self, description, response=None):
except JSONDecodeError:
message = response.text
self.message = f"{description}: {message} ({response.status_code})"
super().__init__(self.message)


class FossologyUnsupported(Error):
"""Endpoint or option not supported"""

def __init__(self, description):
self.message = description
super().__init__(self.message)
6 changes: 1 addition & 5 deletions tests/test_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_upload_summary_with_unknown_group_raises_authorization_error(
)


def test_delete_unknown_upload_unknown_group(foss: Fossology, fake_hash: dict):
def test_delete_if_unknown_upload_raises_error(foss: Fossology, fake_hash: dict):
upload = Upload(
foss.rootFolder,
"Root Folder",
Expand All @@ -234,10 +234,6 @@ def test_delete_unknown_upload_unknown_group(foss: Fossology, fake_hash: dict):
with pytest.raises(FossologyApiError):
foss.delete_upload(upload)

with pytest.raises(AuthorizationError) as excinfo:
foss.delete_upload(upload, group="test")
assert f"Not authorized 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
Expand Down

0 comments on commit 5de8aec

Please sign in to comment.