From e8edf33f1da47f2c29156d3eae09a96807cf1c2f Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 11 Nov 2024 10:18:16 -0800 Subject: [PATCH] back to s3 --- tests/app/aws/test_s3.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/app/aws/test_s3.py b/tests/app/aws/test_s3.py index e4a9c1c07..4e443e6f9 100644 --- a/tests/app/aws/test_s3.py +++ b/tests/app/aws/test_s3.py @@ -255,6 +255,16 @@ def mock_s3_get_object_slowdown(*args, **kwargs): raise ClientError(error_response, "GetObject") +def mock_s3_get_object_no_such_key(*args, **kwargs): + error_response = { + "Error": { + "Code": "NoSuchKey", + "Message": "Couldn't find it", + } + } + raise ClientError(error_response, "GetObject") + + def test_get_job_from_s3_exponential_backoff_on_throttling(mocker): # We try multiple times to retrieve the job, and if we can't we return None mock_get_object = mocker.patch( @@ -266,6 +276,17 @@ def test_get_job_from_s3_exponential_backoff_on_throttling(mocker): assert mock_get_object.call_count == 8 +def test_get_job_from_s3_exponential_backoff_on_no_such_key(mocker): + # We try multiple times to retrieve the job, and if we can't we return None + mock_get_object = mocker.patch( + "app.aws.s3.get_s3_object", side_effect=mock_s3_get_object_slowdown + ) + mocker.patch("app.aws.s3.file_exists", return_value=True) + job = get_job_from_s3("service_id", "job_id") + assert job is None + assert mock_get_object.call_count == 8 + + def test_get_job_from_s3_exponential_backoff_on_random_exception(mocker): # We try multiple times to retrieve the job, and if we can't we return None mock_get_object = mocker.patch("app.aws.s3.get_s3_object", side_effect=Exception())