From a527218638bf13db0e64783164a47a62a990f59f Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 9 Jan 2025 08:07:20 -0800 Subject: [PATCH] fix tests --- tests/notifications_utils/test_s3.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/notifications_utils/test_s3.py b/tests/notifications_utils/test_s3.py index 46b863c4f..8208f6c41 100644 --- a/tests/notifications_utils/test_s3.py +++ b/tests/notifications_utils/test_s3.py @@ -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