From 0bc07307732206fe08249e10d550e01f2c74eecc Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Thu, 24 Oct 2024 10:49:04 -0700 Subject: [PATCH] test exception block in get_job_from_s3 --- tests/app/aws/test_s3.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/app/aws/test_s3.py b/tests/app/aws/test_s3.py index 5cbc7725a..8fc1db819 100644 --- a/tests/app/aws/test_s3.py +++ b/tests/app/aws/test_s3.py @@ -248,6 +248,15 @@ 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_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()) + 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 == 1 + + def test_get_job_from_s3_exponential_backoff_file_not_found(mocker): mock_get_object = mocker.patch("app.aws.s3.get_s3_object", return_value=None) mocker.patch("app.aws.s3.file_exists", return_value=False)