make sure test notifications don't get date subfolders

they just go in the test bucket's root
This commit is contained in:
Leo Hemsted
2019-09-17 17:34:47 +01:00
parent 99eb17fc29
commit d080106cbe
2 changed files with 19 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ from app.celery.letters_pdf_tasks import (
_move_invalid_letter_and_update_status,
_sanitise_precompiled_pdf
)
from app.letters.utils import get_letter_pdf_filename, ScanErrorType
from app.letters.utils import ScanErrorType
from app.models import (
KEY_TYPE_NORMAL,
KEY_TYPE_TEST,
@@ -120,14 +120,25 @@ def test_create_letters_pdf_calls_s3upload(mocker, sample_letter_notification):
create_letters_pdf(sample_letter_notification.id)
filename = get_letter_pdf_filename(
reference=sample_letter_notification.reference,
crown=sample_letter_notification.service.crown
)
mock_s3.assert_called_with(
bucket_name=current_app.config['LETTERS_PDF_BUCKET_NAME'],
file_location=filename,
file_location='2017-12-05/NOTIFY.FOO.D.2.C.C.20171204173100.PDF',
filedata=b'\x00\x01',
region=current_app.config['AWS_REGION']
)
@freeze_time("2017-12-04 17:31:00")
def test_create_letters_pdf_calls_s3upload_for_test_letters(mocker, sample_letter_notification):
mocker.patch('app.celery.letters_pdf_tasks.get_letters_pdf', return_value=(b'\x00\x01', '1'))
mock_s3 = mocker.patch('app.letters.utils.s3upload')
sample_letter_notification.key_type = 'test'
create_letters_pdf(sample_letter_notification.id)
mock_s3.assert_called_with(
bucket_name=current_app.config['TEST_LETTERS_BUCKET_NAME'],
file_location='NOTIFY.FOO.D.2.C.C.20171204173100.PDF',
filedata=b'\x00\x01',
region=current_app.config['AWS_REGION']
)