SIENTIAPDE-1248: Refactor MinIO activity to raise specific exception types for better error handling

This commit is contained in:
Bruno Domingues
2025-10-06 10:58:48 -03:00
parent ec5b9df125
commit 520975e7aa
2 changed files with 11 additions and 11 deletions

View File

@@ -56,7 +56,7 @@ def test___init___failure(mock_boto3_client):
logger = MagicMock()
notification_handler = MagicMock()
with raises(Exception, match='Failed to initialize MinIO client'):
with raises(ConnectionError, match='Failed to initialize MinIO client'):
MinIO(
endpoint_url='http://localhost:9000',
access_key='minioadmin',
@@ -156,7 +156,7 @@ async def test_fetch_file_from_minio_file_not_found(minio):
}
# Act & Assert
with raises(Exception, match='Error fetching file from MinIO'):
with raises(OSError, match='Error fetching file from MinIO'):
await minio.fetch_file_from_minio(input_data)
# Verify notification was sent
@@ -179,7 +179,7 @@ async def test_fetch_file_from_minio_network_error(minio):
}
# Act & Assert
with raises(Exception, match='Error fetching file from MinIO'):
with raises(OSError, match='Error fetching file from MinIO'):
await minio.fetch_file_from_minio(input_data)
minio.send_notification.assert_called_once()
@@ -242,7 +242,7 @@ async def test_delete_file_from_minio_access_denied(minio):
}
# Act & Assert
with raises(Exception, match='Error deleting file from MinIO'):
with raises(OSError, match='Error deleting file from MinIO'):
await minio.delete_file_from_minio(input_data)
# Verify notification was sent
@@ -265,7 +265,7 @@ async def test_delete_file_from_minio_network_error(minio):
}
# Act & Assert
with raises(Exception, match='Error deleting file from MinIO'):
with raises(OSError, match='Error deleting file from MinIO'):
await minio.delete_file_from_minio(input_data)
minio.send_notification.assert_called_once()