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