fix(storage): use RuntimeError instead of bare Exception in SharePoint task
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -335,4 +335,4 @@ def upload_to_sharepoint(self, file_path: str, file_id: int = None, folder_overr
|
|||||||
error_msg = f"Failed to upload {filename} to SharePoint: {str(e)}"
|
error_msg = f"Failed to upload {filename} to SharePoint: {str(e)}"
|
||||||
logger.error("[%s] %s", task_id, error_msg)
|
logger.error("[%s] %s", task_id, error_msg)
|
||||||
log_task_progress(task_id, "upload_to_sharepoint", "failure", error_msg, file_id=file_id)
|
log_task_progress(task_id, "upload_to_sharepoint", "failure", error_msg, file_id=file_id)
|
||||||
raise Exception(error_msg)
|
raise RuntimeError(error_msg) from e
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ class TestUploadToSharepoint:
|
|||||||
|
|
||||||
mock_token.side_effect = ValueError("Token error")
|
mock_token.side_effect = ValueError("Token error")
|
||||||
|
|
||||||
with pytest.raises(Exception, match="Failed to upload"):
|
with pytest.raises(RuntimeError, match="Failed to upload"):
|
||||||
upload_to_sharepoint.apply(args=[str(test_file)], kwargs={"file_id": 1}).get()
|
upload_to_sharepoint.apply(args=[str(test_file)], kwargs={"file_id": 1}).get()
|
||||||
|
|
||||||
@patch("app.tasks.upload_to_sharepoint.upload_large_file_sharepoint")
|
@patch("app.tasks.upload_to_sharepoint.upload_large_file_sharepoint")
|
||||||
|
|||||||
Reference in New Issue
Block a user