mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Rebase pytest 5 changes
Add to field in creation of notification
This commit is contained in:
@@ -265,20 +265,16 @@ def test_download_not_available_to_users_without_dashboard(
|
||||
|
||||
def test_letters_with_status_virus_scan_failed_shows_a_failure_description(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_service_statistics,
|
||||
mock_get_service_data_retention,
|
||||
mock_get_api_keys,
|
||||
):
|
||||
mock_get_notifications(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
is_precompiled_letter=True,
|
||||
noti_status='virus-scan-failed',
|
||||
client_reference='client reference'
|
||||
)
|
||||
notifications = create_notifications(template_type='letter', status='virus-scan-failed', is_precompiled_letter=True,
|
||||
client_reference='client reference')
|
||||
mocker.patch('app.notification_api_client.get_notifications_for_service', return_value=notifications)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
@@ -295,7 +291,6 @@ 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(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_service_statistics,
|
||||
@@ -303,13 +298,10 @@ def test_should_not_show_preview_link_for_precompiled_letters_in_virus_states(
|
||||
mock_get_no_api_keys,
|
||||
letter_status,
|
||||
):
|
||||
mock_get_notifications(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
is_precompiled_letter=True,
|
||||
noti_status=letter_status,
|
||||
client_reference='ref'
|
||||
)
|
||||
notifications = create_notifications(template_type='letter', status=letter_status,
|
||||
is_precompiled_letter=True, client_reference='ref')
|
||||
mocker.patch('app.notification_api_client.get_notifications_for_service', return_value=notifications)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notifications',
|
||||
service_id=service_one['id'],
|
||||
@@ -420,43 +412,12 @@ def test_search_recipient_form(
|
||||
assert field['value'] == expected_search_box_contents
|
||||
|
||||
|
||||
@pytest.mark.parametrize((
|
||||
'message_type,'
|
||||
'api_keys_mock,'
|
||||
'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',
|
||||
),
|
||||
@pytest.mark.parametrize('message_type, expected_search_box_label', [
|
||||
(None, 'Search by email address, phone number or reference'),
|
||||
('sms', 'Search by phone number or reference'),
|
||||
('email', 'Search by email address or reference'),
|
||||
])
|
||||
def test_api_users_are_told_they_can_search_by_reference(
|
||||
def test_api_users_are_told_they_can_search_by_reference_when_service_has_api_keys(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
@@ -465,9 +426,32 @@ def test_api_users_are_told_they_can_search_by_reference(
|
||||
mock_get_service_data_retention,
|
||||
message_type,
|
||||
expected_search_box_label,
|
||||
api_keys_mock,
|
||||
mock_get_api_keys,
|
||||
):
|
||||
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(
|
||||
'main.view_notifications',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
@@ -581,7 +565,6 @@ def test_html_contains_notification_id(
|
||||
|
||||
def test_html_contains_links_for_failed_notifications(
|
||||
client_request,
|
||||
active_user_with_permissions,
|
||||
mock_get_service_statistics,
|
||||
mock_get_service_data_retention,
|
||||
mock_get_no_api_keys,
|
||||
@@ -723,12 +706,15 @@ def test_should_show_address_and_hint_for_letters(
|
||||
mock_get_no_api_keys,
|
||||
mocker,
|
||||
is_precompiled_letter,
|
||||
expected_address,
|
||||
expected_hint
|
||||
):
|
||||
notifications = create_notifications(
|
||||
template_type='letter',
|
||||
subject=expected_hint,
|
||||
is_precompiled_letter=is_precompiled_letter,
|
||||
client_reference=expected_hint,
|
||||
to=expected_address
|
||||
)
|
||||
mocker.patch('app.notification_api_client.get_notifications_for_service', return_value=notifications)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user