mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Show the first line of the address from the to field.
Now persisting the address to the "to" field of the Notification, after the notification has been validated. If the letter is pending validation, then "Checking..." will appear as the identifier for the letter. If the letter has passed validation, then the first line of the address (now persisted in the "to" field) will be displayed, with the client reference underneath. If the letter has failed validation the "Provided as PDF" will show be displayed, which is now the initial value of the "to" field.
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
import pytest
|
||||
import urllib
|
||||
|
||||
from flask import current_app
|
||||
|
||||
from app.s3_client.s3_letter_upload_client import (
|
||||
format_recipient,
|
||||
upload_letter_to_s3,
|
||||
)
|
||||
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')
|
||||
|
||||
recipient = 'Bugs Bunny\n123 Big Hole\nLooney Town'
|
||||
upload_letter_to_s3(
|
||||
'pdf_data',
|
||||
file_location='service_id/upload_id.pdf',
|
||||
status='valid',
|
||||
page_count=3,
|
||||
filename='my_doc')
|
||||
filename='my_doc',
|
||||
recipient=recipient
|
||||
)
|
||||
|
||||
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'},
|
||||
metadata={'status': 'valid', 'page_count': '3', 'filename': 'my_doc',
|
||||
'recipient': urllib.parse.quote(recipient)},
|
||||
region=current_app.config['AWS_REGION']
|
||||
)
|
||||
|
||||
@@ -51,15 +53,3 @@ def test_upload_letter_to_s3_with_message_and_invalid_pages(mocker):
|
||||
},
|
||||
region=current_app.config['AWS_REGION']
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('original_address,expected_address', [
|
||||
('The Queen, Buckingham Palace, SW1 1AA', 'The Queen, Buckingham Palace, SW1 1AA'),
|
||||
('The Queen Buckingham Palace SW1 1AA', 'The Queen Buckingham Palace SW1 1AA'),
|
||||
('The Queen,\nBuckingham Palace,\r\nSW1 1AA', 'The Queen, Buckingham Palace, SW1 1AA'),
|
||||
('The Queen ,,\nBuckingham Palace,\rSW1 1AA,', 'The Queen, Buckingham Palace, SW1 1AA'),
|
||||
(' The Queen\n Buckingham Palace\n SW1 1AA', 'The Queen, Buckingham Palace, SW1 1AA'),
|
||||
("The ’Queen\n Buckingham Palace\n SW1 1AA", "The 'Queen, Buckingham Palace, SW1 1AA"),
|
||||
])
|
||||
def test_format_recipient(original_address, expected_address):
|
||||
assert format_recipient(original_address) == expected_address
|
||||
|
||||
Reference in New Issue
Block a user