mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-28 03:11:40 -05:00
add provider tasks tests
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user