mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Strip the trailing comma on the first line of an address block.
This commit is contained in:
@@ -199,7 +199,7 @@ def uploaded_letter_preview(service_id, file_id):
|
|||||||
status = metadata.get('status')
|
status = metadata.get('status')
|
||||||
error_shortcode = metadata.get('message')
|
error_shortcode = metadata.get('message')
|
||||||
invalid_pages = metadata.get('invalid_pages')
|
invalid_pages = metadata.get('invalid_pages')
|
||||||
recipient = format_recipient(metadata.get('recipient'))
|
recipient = format_recipient(metadata.get('recipient', ''))
|
||||||
|
|
||||||
if invalid_pages:
|
if invalid_pages:
|
||||||
invalid_pages = json.loads(invalid_pages)
|
invalid_pages = json.loads(invalid_pages)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
{% if item.status in ('pending-virus-check', 'virus-scan-failed') %}
|
{% if item.status in ('pending-virus-check', 'virus-scan-failed') %}
|
||||||
<span class="file-list-filename loading-indicator">Checking</span>
|
<span class="file-list-filename loading-indicator">Checking</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="file-list-filename" href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=item.id) }}">{{ item.to.splitlines()[0].lstrip().rstrip(' ,') }}</a>
|
<a class="file-list-filename" href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=item.id) }}">{{ item.to.splitlines()[0].lstrip().rstrip(' ,') if item.to else '' }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p class="file-list-hint">
|
<p class="file-list-hint">
|
||||||
{{ item.preview_of_content }}
|
{{ item.preview_of_content }}
|
||||||
|
|||||||
@@ -276,7 +276,8 @@ def test_letters_with_status_virus_scan_failed_shows_a_failure_description(
|
|||||||
mocker,
|
mocker,
|
||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
is_precompiled_letter=True,
|
is_precompiled_letter=True,
|
||||||
noti_status='virus-scan-failed'
|
noti_status='virus-scan-failed',
|
||||||
|
client_reference='client reference'
|
||||||
)
|
)
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notifications',
|
'main.view_notifications',
|
||||||
@@ -294,6 +295,7 @@ def test_letters_with_status_virus_scan_failed_shows_a_failure_description(
|
|||||||
])
|
])
|
||||||
def test_should_not_show_preview_link_for_precompiled_letters_in_virus_states(
|
def test_should_not_show_preview_link_for_precompiled_letters_in_virus_states(
|
||||||
mocker,
|
mocker,
|
||||||
|
active_user_with_permissions,
|
||||||
client_request,
|
client_request,
|
||||||
service_one,
|
service_one,
|
||||||
mock_get_service_statistics,
|
mock_get_service_statistics,
|
||||||
@@ -301,9 +303,13 @@ def test_should_not_show_preview_link_for_precompiled_letters_in_virus_states(
|
|||||||
mock_get_no_api_keys,
|
mock_get_no_api_keys,
|
||||||
letter_status,
|
letter_status,
|
||||||
):
|
):
|
||||||
notifications = create_notifications(template_type='letter', status=letter_status)
|
mock_get_notifications(
|
||||||
mocker.patch('app.notification_api_client.get_notifications_for_service', return_value=notifications)
|
mocker,
|
||||||
|
active_user_with_permissions,
|
||||||
|
is_precompiled_letter=True,
|
||||||
|
noti_status=letter_status,
|
||||||
|
client_reference='ref'
|
||||||
|
)
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notifications',
|
'main.view_notifications',
|
||||||
service_id=service_one['id'],
|
service_id=service_one['id'],
|
||||||
@@ -414,12 +420,43 @@ def test_search_recipient_form(
|
|||||||
assert field['value'] == expected_search_box_contents
|
assert field['value'] == expected_search_box_contents
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('message_type, expected_search_box_label', [
|
@pytest.mark.parametrize((
|
||||||
(None, 'Search by email address, phone number or reference'),
|
'message_type,'
|
||||||
('sms', 'Search by phone number or reference'),
|
'api_keys_mock,'
|
||||||
('email', 'Search by email address or reference'),
|
'expected_search_box_label,'
|
||||||
|
), [
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
mock_get_no_api_keys,
|
||||||
|
'Search by email address or phone number',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
None,
|
||||||
|
mock_get_api_keys,
|
||||||
|
'Search by email address, phone number or reference',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'sms',
|
||||||
|
mock_get_no_api_keys,
|
||||||
|
'Search by phone number',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'sms',
|
||||||
|
mock_get_api_keys,
|
||||||
|
'Search by phone number or reference',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'email',
|
||||||
|
mock_get_no_api_keys,
|
||||||
|
'Search by email address',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'email',
|
||||||
|
mock_get_api_keys,
|
||||||
|
'Search by email address or reference',
|
||||||
|
),
|
||||||
])
|
])
|
||||||
def test_api_users_are_told_they_can_search_by_reference_when_service_has_api_keys(
|
def test_api_users_are_told_they_can_search_by_reference(
|
||||||
client_request,
|
client_request,
|
||||||
mocker,
|
mocker,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
@@ -428,32 +465,9 @@ def test_api_users_are_told_they_can_search_by_reference_when_service_has_api_ke
|
|||||||
mock_get_service_data_retention,
|
mock_get_service_data_retention,
|
||||||
message_type,
|
message_type,
|
||||||
expected_search_box_label,
|
expected_search_box_label,
|
||||||
mock_get_api_keys,
|
api_keys_mock,
|
||||||
):
|
|
||||||
page = client_request.get(
|
|
||||||
'main.view_notifications',
|
|
||||||
service_id=SERVICE_ONE_ID,
|
|
||||||
message_type=message_type,
|
|
||||||
)
|
|
||||||
assert page.select_one('label[for=to]').text.strip() == expected_search_box_label
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('message_type, expected_search_box_label', [
|
|
||||||
(None, 'Search by email address or phone number'),
|
|
||||||
('sms', 'Search by phone number'),
|
|
||||||
('email', 'Search by email address'),
|
|
||||||
])
|
|
||||||
def test_api_users_are_not_told_they_can_search_by_reference_when_service_has_no_api_keys(
|
|
||||||
client_request,
|
|
||||||
mocker,
|
|
||||||
fake_uuid,
|
|
||||||
mock_get_notifications,
|
|
||||||
mock_get_service_statistics,
|
|
||||||
mock_get_service_data_retention,
|
|
||||||
message_type,
|
|
||||||
expected_search_box_label,
|
|
||||||
mock_get_no_api_keys,
|
|
||||||
):
|
):
|
||||||
|
api_keys_mock(mocker, fake_uuid)
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notifications',
|
'main.view_notifications',
|
||||||
service_id=SERVICE_ONE_ID,
|
service_id=SERVICE_ONE_ID,
|
||||||
@@ -697,11 +711,11 @@ def test_sending_status_hint_displays_correctly_on_notifications_page(
|
|||||||
assert bool(page.select('.align-with-message-body')) is single_line
|
assert bool(page.select('.align-with-message-body')) is single_line
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("is_precompiled_letter,expected_hint", [
|
@pytest.mark.parametrize("is_precompiled_letter,expected_address,expected_hint", [
|
||||||
(True, "Provided as PDF"),
|
(True, "Full Name,\nFirst address line\npostcode", "ref"),
|
||||||
(False, "template subject")
|
(False, "Full Name,\nFirst address line\npostcode", "template subject")
|
||||||
])
|
])
|
||||||
def test_should_expected_hint_for_letters(
|
def test_should_show_address_and_hint_for_letters(
|
||||||
client_request,
|
client_request,
|
||||||
service_one,
|
service_one,
|
||||||
mock_get_service_statistics,
|
mock_get_service_statistics,
|
||||||
@@ -724,4 +738,5 @@ def test_should_expected_hint_for_letters(
|
|||||||
message_type='letter',
|
message_type='letter',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert page.select_one('a.file-list-filename').text == 'Full Name'
|
||||||
assert page.find('p', {'class': 'file-list-hint'}).text.strip() == expected_hint
|
assert page.find('p', {'class': 'file-list-hint'}).text.strip() == expected_hint
|
||||||
|
|||||||
@@ -535,6 +535,7 @@ def test_send_uploaded_letter_when_metadata_states_pdf_is_invalid(mocker, servic
|
|||||||
('The Queen,\nBuckingham Palace,\r\nSW1 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 ,,\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):
|
def test_format_recipient(original_address, expected_address):
|
||||||
assert format_recipient(urllib.parse.quote(original_address)) == expected_address
|
assert format_recipient(urllib.parse.quote(original_address)) == expected_address
|
||||||
|
|||||||
@@ -1791,6 +1791,7 @@ def mock_get_notifications(
|
|||||||
return notification_json(
|
return notification_json(
|
||||||
service_id,
|
service_id,
|
||||||
template=template,
|
template=template,
|
||||||
|
to=to,
|
||||||
rows=rows,
|
rows=rows,
|
||||||
job=job,
|
job=job,
|
||||||
with_links=True if count_pages is None else count_pages,
|
with_links=True if count_pages is None else count_pages,
|
||||||
@@ -2879,6 +2880,14 @@ def mock_create_service_inbound_api(mocker):
|
|||||||
return mocker.patch('app.service_api_client.create_service_inbound_api', side_effect=_create_service_inbound_api)
|
return mocker.patch('app.service_api_client.create_service_inbound_api', side_effect=_create_service_inbound_api)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='function')
|
||||||
|
def mock_delete_service_inbound_api(mocker):
|
||||||
|
return mocker.patch(
|
||||||
|
'app.service_api_client.delete_service_callback_api',
|
||||||
|
side_effect=lambda service_id: None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_update_service_inbound_api(mocker):
|
def mock_update_service_inbound_api(mocker):
|
||||||
def _update_service_inbound_api(service_id, url, bearer_token, user_id, inbound_api_id):
|
def _update_service_inbound_api(service_id, url, bearer_token, user_id, inbound_api_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user