Show recipient when about to send uploaded letter

The recipient of the letter now displays at the bottom of the page when
previewing a valid letter. The template preview `/precompiled/sanitise`
endpoint returns the address, but we format it to display on a single
line with commas between each line. We also need to convert the
recipient address to ASCII so that it can be stored as S3 metadata.
This commit is contained in:
Katie Smith
2019-11-08 09:56:59 +00:00
parent 21a59598b2
commit a542047581
5 changed files with 75 additions and 10 deletions

View File

@@ -1,6 +1,10 @@
import pytest
from flask import current_app
from app.s3_client.s3_letter_upload_client import upload_letter_to_s3
from app.s3_client.s3_letter_upload_client import (
format_recipient,
upload_letter_to_s3,
)
def test_upload_letter_to_s3(mocker):
@@ -47,3 +51,15 @@ 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