fix tests

This commit is contained in:
Kenneth Kehl
2025-01-09 08:07:20 -08:00
parent 5cedd6427d
commit a527218638

View File

@@ -13,7 +13,11 @@ content_type = "binary/octet-stream"
def test_s3upload_save_file_to_bucket(mocker):
mocked = mocker.patch("notifications_utils.s3.Session.resource")
mock_s3_client = mocker.Mock()
mocked = mocker.patch(
"notification_utils.s3.get_s3_client", return_value=mock_s3_client
)
s3upload(
filedata=contents, region=region, bucket_name=bucket, file_location=location
)
@@ -27,7 +31,9 @@ def test_s3upload_save_file_to_bucket(mocker):
def test_s3upload_save_file_to_bucket_with_contenttype(mocker):
content_type = "image/png"
mocked = mocker.patch("notifications_utils.s3.Session.resource")
mock_s3_client = mocker.Mock()
mocked = mocker.patch("app.aws.s3.get_s3_client", return_value=mock_s3_client)
s3upload(
filedata=contents,
region=region,
@@ -44,7 +50,9 @@ def test_s3upload_save_file_to_bucket_with_contenttype(mocker):
def test_s3upload_raises_exception(app, mocker):
mocked = mocker.patch("notifications_utils.s3.Session.resource")
mock_s3_client = mocker.Mock()
mocked = mocker.patch("app.aws.s3.get_s3_client", return_value=mock_s3_client)
response = {"Error": {"Code": 500}}
exception = botocore.exceptions.ClientError(response, "Bad exception")
mocked.return_value.Object.return_value.put.side_effect = exception