mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 01:48:33 -04:00
Display the two new virus states for letters
Precompiled letters can now have two additional states: * pending-virus-check * virus-scan-failed Both new states should show in the notifications dashboard, and virus-scan-failed should appear as an error state, with a descriptive message. You should not be able to preview a letter in one of the two new states, so the preview link has been removed for precompiled letters in these states.
This commit is contained in:
@@ -26,14 +26,14 @@ from app.main.views.jobs import get_status_filters, get_time_left
|
||||
(
|
||||
'',
|
||||
[
|
||||
'created', 'pending', 'sending',
|
||||
'created', 'pending', 'sending', 'pending-virus-check',
|
||||
'delivered', 'sent',
|
||||
'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
|
||||
'failed', 'temporary-failure', 'permanent-failure', 'technical-failure', 'virus-scan-failed',
|
||||
]
|
||||
),
|
||||
(
|
||||
'sending',
|
||||
['sending', 'created', 'pending']
|
||||
['sending', 'created', 'pending', 'pending-virus-check']
|
||||
),
|
||||
(
|
||||
'delivered',
|
||||
@@ -41,7 +41,7 @@ from app.main.views.jobs import get_status_filters, get_time_left
|
||||
),
|
||||
(
|
||||
'failed',
|
||||
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure', 'virus-scan-failed']
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -135,6 +135,60 @@ def test_can_show_notifications(
|
||||
assert json_content.keys() == {'counts', 'notifications'}
|
||||
|
||||
|
||||
def test_letters_with_status_virus_scan_failed_shows_a_failure_description(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
logged_in_client,
|
||||
service_one,
|
||||
mock_get_detailed_service,
|
||||
):
|
||||
mock_get_notifications(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
is_precompiled_letter=True,
|
||||
noti_status='virus-scan-failed'
|
||||
)
|
||||
response = logged_in_client.get(url_for(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
message_type='letter',
|
||||
status='',
|
||||
))
|
||||
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
error_description = page.find('div', attrs={'class': 'table-field-status-error'}).text.strip()
|
||||
assert 'Virus detected\n' in error_description
|
||||
|
||||
|
||||
@pytest.mark.parametrize('letter_status', [
|
||||
'pending-virus-check', 'virus-scan-failed'
|
||||
])
|
||||
def test_should_not_show_preview_link_for_precompiled_letters_in_virus_states(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
logged_in_client,
|
||||
service_one,
|
||||
mock_get_detailed_service,
|
||||
letter_status,
|
||||
):
|
||||
mock_get_notifications(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
is_precompiled_letter=True,
|
||||
noti_status=letter_status
|
||||
)
|
||||
response = logged_in_client.get(url_for(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
message_type='letter',
|
||||
status='',
|
||||
))
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
|
||||
assert not page.find('a', attrs={'class': 'file-list-filename'})
|
||||
|
||||
|
||||
def test_shows_message_when_no_notifications(
|
||||
client_request,
|
||||
mock_get_detailed_service,
|
||||
|
||||
@@ -89,6 +89,27 @@ def test_letter_notifications_should_have_link_to_view_letter(
|
||||
assert (page.select_one('details a') is not None) == has_links
|
||||
|
||||
|
||||
@pytest.mark.parametrize('status', [
|
||||
'pending-virus-check', 'virus-scan-failed'
|
||||
])
|
||||
def test_should_not_have_link_to_view_letter_for_precompiled_letters_in_virus_states(
|
||||
client_request,
|
||||
api_user_active,
|
||||
fake_uuid,
|
||||
mock_has_permissions,
|
||||
mocker,
|
||||
status
|
||||
):
|
||||
mock_get_notifications(mocker, api_user_active, noti_status=status)
|
||||
|
||||
page = client_request.get(
|
||||
'main.api_integration',
|
||||
service_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert not page.select_one('details a')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('client_reference, shows_ref', [
|
||||
('foo', True),
|
||||
(None, False),
|
||||
|
||||
@@ -49,14 +49,14 @@ def test_get_jobs_shows_page_links(
|
||||
(
|
||||
'',
|
||||
[
|
||||
'created', 'pending', 'sending',
|
||||
'created', 'pending', 'sending', 'pending-virus-check',
|
||||
'delivered', 'sent',
|
||||
'failed', 'temporary-failure', 'permanent-failure', 'technical-failure',
|
||||
'failed', 'temporary-failure', 'permanent-failure', 'technical-failure', 'virus-scan-failed',
|
||||
]
|
||||
),
|
||||
(
|
||||
'sending',
|
||||
['sending', 'created', 'pending']
|
||||
['sending', 'created', 'pending', 'pending-virus-check']
|
||||
),
|
||||
(
|
||||
'delivered',
|
||||
@@ -64,7 +64,7 @@ def test_get_jobs_shows_page_links(
|
||||
),
|
||||
(
|
||||
'failed',
|
||||
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure', 'virus-scan-failed']
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -200,12 +200,14 @@ def test_should_show_letter_job(
|
||||
'created',
|
||||
'pending',
|
||||
'sending',
|
||||
'pending-virus-check',
|
||||
'delivered',
|
||||
'sent',
|
||||
'failed',
|
||||
'temporary-failure',
|
||||
'permanent-failure',
|
||||
'technical-failure',
|
||||
'virus-scan-failed',
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -1766,6 +1766,7 @@ def mock_get_notifications(
|
||||
redact_personalisation=False,
|
||||
is_precompiled_letter=False,
|
||||
client_reference=None,
|
||||
noti_status=None,
|
||||
):
|
||||
def _get_notifications(
|
||||
service_id,
|
||||
@@ -1807,6 +1808,7 @@ def mock_get_notifications(
|
||||
personalisation=personalisation,
|
||||
template_type=diff_template_type,
|
||||
client_reference=client_reference,
|
||||
status=noti_status,
|
||||
)
|
||||
|
||||
return mocker.patch(
|
||||
|
||||
Reference in New Issue
Block a user