Files
notifications-admin/tests/app/s3_client/test_s3_letter_upload_client.py
Katie Smith 11543e15be Store all data about uploaded letters in the S3 metadata
We had been storing whether or not a file was valid in the S3 metadata,
but using the query string of the URL to store the original filename
and the page count. This meant that if you tried to view the preview
letter page without the query string you would see a `500`. It was
possible for this to happen if you were signed out of Notify while on
the preview page - you would be redirected back to the preview page but
without the query string, causing an error.
2019-10-08 15:34:00 +01:00

23 lines
713 B
Python

from flask import current_app
from app.s3_client.s3_letter_upload_client import upload_letter_to_s3
def test_upload_letter_to_s3(mocker):
s3_mock = mocker.patch('app.s3_client.s3_letter_upload_client.utils_s3upload')
upload_letter_to_s3(
'pdf_data',
file_location='service_id/upload_id.pdf',
status='valid',
page_count=3,
filename='my_doc')
s3_mock.assert_called_once_with(
bucket_name=current_app.config['TRANSIENT_UPLOADED_LETTERS'],
file_location='service_id/upload_id.pdf',
filedata='pdf_data',
metadata={'status': 'valid', 'page_count': '3', 'filename': 'my_doc'},
region=current_app.config['AWS_REGION']
)