add provider tasks tests

This commit is contained in:
Kenneth Kehl
2024-10-22 14:33:17 -07:00
parent 205a1da257
commit 5d72b578c7
2 changed files with 20 additions and 2 deletions

View File

@@ -209,7 +209,7 @@
"filename": "tests/app/aws/test_s3.py",
"hashed_secret": "67a74306b06d0c01624fe0d0249a570f4d093747",
"is_verified": false,
"line_number": 29,
"line_number": 30,
"is_secret": false
}
],
@@ -384,5 +384,5 @@
}
]
},
"generated_at": "2024-09-27T16:42:53Z"
"generated_at": "2024-10-22T21:33:13Z"
}

View File

@@ -13,6 +13,7 @@ from app.aws.s3 import (
get_personalisation_from_s3,
get_phone_number_from_s3,
get_s3_file,
list_s3_objects,
remove_csv_object,
remove_s3_object,
)
@@ -59,6 +60,23 @@ def test_cleanup_old_s3_objects(mocker):
mock_remove_csv_object.assert_called_once_with("A")
def test_list_s3_objects(mocker):
mock_s3_client = mocker.Mock()
mocker.patch("app.aws.s3.get_s3_client", return_value=mock_s3_client)
lastmod30 = aware_utcnow() - timedelta(days=30)
lastmod3 = aware_utcnow() - timedelta(days=3)
mock_s3_client.list_objects_v2.return_value = {
"Contents": [
{"Key": "A", "LastModified": lastmod30},
{"Key": "B", "LastModified": lastmod3},
]
}
result = list_s3_objects()
assert result == ["B"]
def test_get_s3_file_makes_correct_call(notify_api, mocker):
get_s3_mock = mocker.patch("app.aws.s3.get_s3_object")
get_s3_file(