mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Fix the folder returned for a pdf letter.
Using the created at date for the folder is not always going to work because the pdf created_at date could be just before the cut off date but virus scan and validation has yet to happen. By the time the letters is in the created state, the letter goes into the next days bucket. It can also happen if the letters is stuck in `pending-virus-scan` and we need to restart the task, and the letters is in a different folder.
This commit is contained in:
@@ -27,6 +27,7 @@ def _sample_precompiled_letter_notification(sample_letter_notification):
|
||||
sample_letter_notification.reference = 'foo'
|
||||
with freeze_time(FROZEN_DATE_TIME):
|
||||
sample_letter_notification.created_at = datetime.utcnow()
|
||||
sample_letter_notification.updated_at = datetime.utcnow()
|
||||
return sample_letter_notification
|
||||
|
||||
|
||||
@@ -42,6 +43,7 @@ def _sample_precompiled_letter_notification_using_test_key(sample_precompiled_le
|
||||
])
|
||||
def test_get_bucket_name_and_prefix_for_notification_valid_notification(sample_notification, created_at, folder):
|
||||
sample_notification.created_at = created_at
|
||||
sample_notification.updated_at = created_at
|
||||
|
||||
bucket, bucket_prefix = get_bucket_name_and_prefix_for_notification(sample_notification)
|
||||
|
||||
@@ -52,6 +54,19 @@ def test_get_bucket_name_and_prefix_for_notification_valid_notification(sample_n
|
||||
).upper()
|
||||
|
||||
|
||||
def test_get_bucket_name_and_prefix_for_notification_get_from_sent_at_date(sample_notification):
|
||||
sample_notification.created_at = datetime(2019, 8, 1, 17, 35)
|
||||
sample_notification.sent_at = datetime(2019, 8, 2, 17, 45)
|
||||
|
||||
bucket, bucket_prefix = get_bucket_name_and_prefix_for_notification(sample_notification)
|
||||
|
||||
assert bucket == current_app.config['LETTERS_PDF_BUCKET_NAME']
|
||||
assert bucket_prefix == '{folder}/NOTIFY.{reference}'.format(
|
||||
folder='2019-08-02',
|
||||
reference=sample_notification.reference
|
||||
).upper()
|
||||
|
||||
|
||||
@freeze_time(FROZEN_DATE_TIME)
|
||||
def test_get_bucket_name_and_prefix_for_notification_precompiled_letter_using_test_key(
|
||||
sample_precompiled_letter_notification_using_test_key
|
||||
|
||||
Reference in New Issue
Block a user