mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
post-gray test updates
This commit is contained in:
@@ -527,9 +527,9 @@ def test_organisation_services_shows_live_services_and_usage_with_count_of_1(
|
||||
|
||||
@freeze_time("2020-02-20 20:20")
|
||||
@pytest.mark.parametrize('financial_year, expected_selected', (
|
||||
(2017, '2017 to 2018 financial year'),
|
||||
(2018, '2018 to 2019 financial year'),
|
||||
(2019, '2019 to 2020 financial year'),
|
||||
(2017, '2017 to 2018 fiscal year'),
|
||||
(2018, '2018 to 2019 fiscal year'),
|
||||
(2019, '2019 to 2020 fiscal year'),
|
||||
))
|
||||
def test_organisation_services_filters_by_financial_year(
|
||||
client_request,
|
||||
@@ -551,9 +551,9 @@ def test_organisation_services_filters_by_financial_year(
|
||||
)
|
||||
mock.assert_called_once_with(ORGANISATION_ID, financial_year)
|
||||
assert normalize_spaces(page.select_one('.pill').text) == (
|
||||
'2019 to 2020 financial year '
|
||||
'2018 to 2019 financial year '
|
||||
'2017 to 2018 financial year'
|
||||
'2019 to 2020 fiscal year '
|
||||
'2018 to 2019 fiscal year '
|
||||
'2017 to 2018 fiscal year'
|
||||
)
|
||||
assert normalize_spaces(page.select_one('.pill-item--selected').text) == (
|
||||
expected_selected
|
||||
|
||||
@@ -60,11 +60,11 @@ def mock_get_service_settings_page_common(
|
||||
'Service name Test Service Change service name',
|
||||
'Sign-in method Text message code Change sign-in method',
|
||||
|
||||
'Label Value Action',
|
||||
'Send emails On Change your settings for sending emails',
|
||||
'Reply-to email addresses Not set Manage reply-to email addresses',
|
||||
'Email branding GOV.UK Change email branding',
|
||||
'Send files by email contact_us@gsa.gov Manage sending files by email',
|
||||
# 'Label Value Action',
|
||||
# 'Send emails On Change your settings for sending emails',
|
||||
# 'Reply-to email addresses Not set Manage reply-to email addresses',
|
||||
# 'Email branding GOV.UK Change email branding',
|
||||
# 'Send files by email contact_us@gsa.gov Manage sending files by email',
|
||||
|
||||
'Label Value Action',
|
||||
'Send text messages On Change your settings for sending text messages',
|
||||
@@ -79,11 +79,11 @@ def mock_get_service_settings_page_common(
|
||||
'Service name Test Service Change service name',
|
||||
'Sign-in method Text message code Change sign-in method',
|
||||
|
||||
'Label Value Action',
|
||||
'Send emails On Change your settings for sending emails',
|
||||
'Reply-to email addresses Not set Manage reply-to email addresses',
|
||||
'Email branding GOV.UK Change email branding',
|
||||
'Send files by email contact_us@gsa.gov Manage sending files by email',
|
||||
# 'Label Value Action',
|
||||
# 'Send emails On Change your settings for sending emails',
|
||||
# 'Reply-to email addresses Not set Manage reply-to email addresses',
|
||||
# 'Email branding GOV.UK Change email branding',
|
||||
# 'Send files by email contact_us@gsa.gov Manage sending files by email',
|
||||
|
||||
'Label Value Action',
|
||||
'Send text messages On Change your settings for sending text messages',
|
||||
@@ -189,6 +189,7 @@ def test_organisation_name_links_to_org_dashboard(
|
||||
assert normalize_spaces(org_row.find('a').text) == 'Test organisation'
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Email currently deactivated")
|
||||
@pytest.mark.parametrize('service_contact_link,expected_text', [
|
||||
('contact.me@gsa.gov', 'Send files by email contact.me@gsa.gov Manage sending files by email'),
|
||||
(None, 'Send files by email Not set up Manage sending files by email'),
|
||||
@@ -228,11 +229,11 @@ def test_send_files_by_email_row_on_settings_page(
|
||||
'Service name service one Change service name',
|
||||
'Sign-in method Text message code Change sign-in method',
|
||||
|
||||
'Label Value Action',
|
||||
'Send emails On Change your settings for sending emails',
|
||||
'Reply-to email addresses test@example.com Manage reply-to email addresses',
|
||||
'Email branding Organisation name Change email branding',
|
||||
'Send files by email Not set up Manage sending files by email',
|
||||
# 'Label Value Action',
|
||||
# 'Send emails On Change your settings for sending emails',
|
||||
# 'Reply-to email addresses test@example.com Manage reply-to email addresses',
|
||||
# 'Email branding Organisation name Change email branding',
|
||||
# 'Send files by email Not set up Manage sending files by email',
|
||||
|
||||
'Label Value Action',
|
||||
'Send text messages On Change your settings for sending text messages',
|
||||
@@ -241,20 +242,17 @@ def test_send_files_by_email_row_on_settings_page(
|
||||
'Send international text messages On Change your settings for sending international text messages',
|
||||
'Receive text messages On Change your settings for receiving text messages',
|
||||
|
||||
# 'Label Value Action',
|
||||
# 'Send letters Off Change your settings for sending letters',
|
||||
|
||||
]),
|
||||
(['email', 'sms', 'email_auth'], [
|
||||
|
||||
'Service name service one Change service name',
|
||||
'Sign-in method Email link or text message code Change sign-in method',
|
||||
|
||||
'Label Value Action',
|
||||
'Send emails On Change your settings for sending emails',
|
||||
'Reply-to email addresses test@example.com Manage reply-to email addresses',
|
||||
'Email branding Organisation name Change email branding',
|
||||
'Send files by email Not set up Manage sending files by email',
|
||||
# 'Label Value Action',
|
||||
# 'Send emails On Change your settings for sending emails',
|
||||
# 'Reply-to email addresses test@example.com Manage reply-to email addresses',
|
||||
# 'Email branding Organisation name Change email branding',
|
||||
# 'Send files by email Not set up Manage sending files by email',
|
||||
|
||||
'Label Value Action',
|
||||
'Send text messages On Change your settings for sending text messages',
|
||||
@@ -263,28 +261,7 @@ def test_send_files_by_email_row_on_settings_page(
|
||||
'Send international text messages Off Change your settings for sending international text messages',
|
||||
'Receive text messages Off Change your settings for receiving text messages',
|
||||
|
||||
# 'Label Value Action',
|
||||
# 'Send letters Off Change your settings for sending letters',
|
||||
|
||||
]),
|
||||
# (['letter'], [
|
||||
|
||||
# 'Service name service one Change service name',
|
||||
# 'Sign-in method Text message code Change sign-in method',
|
||||
|
||||
# 'Label Value Action',
|
||||
# 'Send emails Off Change your settings for sending emails',
|
||||
|
||||
# 'Label Value Action',
|
||||
# 'Send text messages Off Change your settings for sending text messages',
|
||||
|
||||
# 'Label Value Action',
|
||||
# 'Send letters On Change your settings for sending letters',
|
||||
# 'Send international letters Off Change',
|
||||
# 'Sender addresses 1 Example Street Manage sender addresses',
|
||||
# 'Letter branding Not set Change letter branding',
|
||||
|
||||
# ]),
|
||||
])
|
||||
def test_should_show_overview_for_service_with_more_things_set(
|
||||
client_request,
|
||||
@@ -1934,6 +1911,7 @@ def test_route_for_platform_admin(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Email currently deactivated")
|
||||
def test_and_more_hint_appears_on_settings_with_more_than_just_a_single_sender(
|
||||
client_request,
|
||||
service_one,
|
||||
@@ -4560,6 +4538,7 @@ def test_update_service_organisation_does_not_update_if_same_value(
|
||||
assert mock_update_service_organisation.called is False
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Email currently deactivated")
|
||||
@pytest.mark.parametrize('single_branding_option, expected_href', [
|
||||
(True, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding/something-else'),
|
||||
# (False, f'/services/{SERVICE_ONE_ID}/service-settings/email-branding'),
|
||||
|
||||
@@ -478,26 +478,6 @@ def test_download_inbox_strips_formulae(
|
||||
assert expected_cell in response.get_data(as_text=True).split('\r\n')[1]
|
||||
|
||||
|
||||
def test_returned_letters_not_visible_if_service_has_no_returned_letters(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_get_service_templates_when_no_templates_exist,
|
||||
mock_has_no_jobs,
|
||||
mock_get_service_statistics,
|
||||
mock_get_template_statistics,
|
||||
mock_get_annual_usage_for_service,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
mock_get_inbound_sms_summary,
|
||||
mock_get_returned_letter_statistics_with_no_returned_letters,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.service_dashboard',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
)
|
||||
assert not page.select('#total-returned-letters')
|
||||
|
||||
|
||||
def test_should_show_recent_templates_on_dashboard(
|
||||
client_request,
|
||||
mocker,
|
||||
@@ -604,7 +584,7 @@ def test_should_show_redirect_from_template_history(
|
||||
)
|
||||
|
||||
|
||||
@freeze_time("2016-07-01 12:00") # 4 months into 2016 financial year
|
||||
@freeze_time("2017-01-01 12:00") # 4 months into 2016 financial year
|
||||
@pytest.mark.parametrize('extra_args', [
|
||||
{},
|
||||
{'year': '2016'},
|
||||
@@ -630,8 +610,8 @@ def test_should_show_monthly_breakdown_of_template_usage(
|
||||
'2'
|
||||
)
|
||||
|
||||
assert len(table_rows) == len(['April'])
|
||||
assert len(page.select('.table-no-data')) == len(['May', 'June', 'July'])
|
||||
assert len(table_rows) == len(['October'])
|
||||
assert len(page.select('.table-no-data')) == len(['November', 'December', 'January'])
|
||||
|
||||
|
||||
def test_anyone_can_see_monthly_breakdown(
|
||||
@@ -653,23 +633,6 @@ def test_anyone_can_see_monthly_breakdown(
|
||||
)
|
||||
|
||||
|
||||
def test_monthly_shows_letters_in_breakdown(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_monthly_notification_stats,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.monthly',
|
||||
service_id=service_one['id']
|
||||
)
|
||||
|
||||
columns = page.select('.table-field-left-aligned .big-number-label')
|
||||
|
||||
assert normalize_spaces(columns[0].text) == 'emails'
|
||||
assert normalize_spaces(columns[1].text) == 'text messages'
|
||||
assert normalize_spaces(columns[2].text) == 'letters'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint', [
|
||||
'main.monthly',
|
||||
'main.template_usage',
|
||||
@@ -687,9 +650,9 @@ def test_stats_pages_show_last_3_years(
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select_one('.pill').text) == (
|
||||
'2014 to 2015 financial year '
|
||||
'2013 to 2014 financial year '
|
||||
'2012 to 2013 financial year'
|
||||
'2014 to 2015 fiscal year '
|
||||
'2013 to 2014 fiscal year '
|
||||
'2012 to 2013 fiscal year'
|
||||
)
|
||||
|
||||
|
||||
@@ -703,7 +666,7 @@ def test_monthly_has_equal_length_tables(
|
||||
service_id=service_one['id']
|
||||
)
|
||||
|
||||
assert page.select_one('.table-field-headings th').get('width') == "25%"
|
||||
assert page.select_one('.table-field-headings th').get('width') == "33%"
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
@@ -894,31 +857,27 @@ def test_usage_page(
|
||||
|
||||
nav = page.find('ul', {'class': 'pill'})
|
||||
unselected_nav_links = nav.select('a:not(.pill-item--selected)')
|
||||
assert normalize_spaces(nav.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 financial year'
|
||||
assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 financial year'
|
||||
assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 financial year'
|
||||
assert normalize_spaces(nav.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 fiscal year'
|
||||
assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 fiscal year'
|
||||
assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 fiscal year'
|
||||
|
||||
annual_usage = page.find_all('div', {'class': 'govuk-grid-column-one-half'})
|
||||
# print(annual_usage)
|
||||
|
||||
# annual stats are shown in two rows, each with three column; email is col 1
|
||||
email_column = normalize_spaces(annual_usage[0].text + annual_usage[2].text)
|
||||
assert 'Emails' in email_column
|
||||
assert '1,000 sent' in email_column
|
||||
# email_column = normalize_spaces(annual_usage[0].text + annual_usage[2].text)
|
||||
# assert 'Emails' in email_column
|
||||
# assert '1,000 sent' in email_column
|
||||
|
||||
sms_column = normalize_spaces(annual_usage[1].text + annual_usage[3].text)
|
||||
sms_column = normalize_spaces(annual_usage[0].text + annual_usage[1].text)
|
||||
assert 'Text messages' in sms_column
|
||||
assert '251,800 sent' in sms_column
|
||||
assert '250,000 free allowance' in sms_column
|
||||
assert '0 free allowance remaining' in sms_column
|
||||
assert '$29.85 spent' in sms_column
|
||||
assert '$29.85 spent' not in sms_column
|
||||
assert '1,500 at 1.65 pence' in sms_column
|
||||
assert '300 at 1.70 pence' in sms_column
|
||||
|
||||
# letter_column = normalize_spaces(annual_usage[2].text + annual_usage[5].text)
|
||||
# assert 'Letters' in letter_column
|
||||
# assert '100 sent' in letter_column
|
||||
# assert '$30.00 spent' in letter_column
|
||||
|
||||
|
||||
@freeze_time("2012-03-31 12:12:12")
|
||||
def test_usage_page_no_sms_spend(
|
||||
@@ -943,11 +902,11 @@ def test_usage_page_no_sms_spend(
|
||||
)
|
||||
|
||||
annual_usage = page.find_all('div', {'class': 'govuk-grid-column-one-half'})
|
||||
sms_column = normalize_spaces(annual_usage[1].text + annual_usage[3].text)
|
||||
sms_column = normalize_spaces(annual_usage[0].text + annual_usage[1].text)
|
||||
assert 'Text messages' in sms_column
|
||||
assert '250,000 free allowance' in sms_column
|
||||
assert '249,000 free allowance remaining' in sms_column
|
||||
assert '$0.00 spent' in sms_column
|
||||
assert '$0.00 spent' not in sms_column
|
||||
assert 'pence per message' not in sms_column
|
||||
|
||||
|
||||
@@ -962,18 +921,14 @@ def test_usage_page_monthly_breakdown(
|
||||
page = client_request.get('main.usage', service_id=SERVICE_ONE_ID)
|
||||
monthly_breakdown = normalize_spaces(page.find('table').text)
|
||||
|
||||
assert 'April' in monthly_breakdown
|
||||
assert 'October' in monthly_breakdown
|
||||
assert '249,860 free text messages' in monthly_breakdown
|
||||
|
||||
assert 'February' in monthly_breakdown
|
||||
assert '$29.55' in monthly_breakdown
|
||||
assert '$16.40' in monthly_breakdown
|
||||
assert '140 free text messages' in monthly_breakdown
|
||||
assert '960 text messages at 1.65p' in monthly_breakdown
|
||||
assert '33 text messages at 1.70p' in monthly_breakdown
|
||||
# assert '5 first class letters at 33p' in monthly_breakdown
|
||||
# assert '10 second class letters at 31p' in monthly_breakdown
|
||||
# assert '3 international letters at 55p' in monthly_breakdown
|
||||
# assert '7 international letters at 84p' in monthly_breakdown
|
||||
|
||||
assert 'March' in monthly_breakdown
|
||||
assert '$20.91' in monthly_breakdown
|
||||
@@ -982,8 +937,8 @@ def test_usage_page_monthly_breakdown(
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'now, expected_number_of_months', [
|
||||
(freeze_time("2017-03-31 11:09:00.061258"), 12),
|
||||
(freeze_time("2017-01-01 11:09:00.061258"), 10)
|
||||
(freeze_time("2017-03-31 11:09:00.061258"), 6),
|
||||
(freeze_time("2017-01-01 11:09:00.061258"), 4)
|
||||
]
|
||||
)
|
||||
def test_usage_page_monthly_breakdown_shows_months_so_far(
|
||||
@@ -1001,25 +956,6 @@ def test_usage_page_monthly_breakdown_shows_months_so_far(
|
||||
assert len(rows) == expected_number_of_months
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Skipping letter-specific test")
|
||||
@freeze_time("2012-03-31 12:12:12")
|
||||
def test_usage_page_letter_breakdown_ordered_by_postage_and_rate(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_monthly_usage_for_service,
|
||||
mock_get_annual_usage_for_service,
|
||||
mock_get_free_sms_fragment_limit
|
||||
):
|
||||
page = client_request.get('main.usage', service_id=SERVICE_ONE_ID)
|
||||
row_for_feb = page.find('table').find_all('tr', class_='table-row')[10]
|
||||
postage_details = row_for_feb.find_all('li', class_='tabular-numbers')
|
||||
|
||||
assert normalize_spaces(postage_details[3].text) == '5 first class letters at 33p'
|
||||
assert normalize_spaces(postage_details[4].text) == '10 second class letters at 31p'
|
||||
assert normalize_spaces(postage_details[5].text) == '3 international letters at 55p'
|
||||
assert normalize_spaces(postage_details[6].text) == '7 international letters at 84p'
|
||||
|
||||
|
||||
def test_usage_page_with_0_free_allowance(
|
||||
mocker,
|
||||
client_request,
|
||||
@@ -1037,7 +973,7 @@ def test_usage_page_with_0_free_allowance(
|
||||
)
|
||||
|
||||
annual_usage = page.select('main .govuk-grid-column-one-half')
|
||||
sms_column = normalize_spaces(annual_usage[1].text)
|
||||
sms_column = normalize_spaces(annual_usage[0].text)
|
||||
|
||||
assert '0 free allowance' in sms_column
|
||||
assert 'free allowance remaining' not in sms_column
|
||||
@@ -1129,11 +1065,11 @@ def test_menu_send_messages(
|
||||
'main.choose_template',
|
||||
service_id=service_one['id'],
|
||||
) in page
|
||||
assert url_for('main.uploads', service_id=service_one['id']) in page
|
||||
# assert url_for('main.uploads', service_id=service_one['id']) in page
|
||||
assert url_for('main.manage_users', service_id=service_one['id']) in page
|
||||
|
||||
assert url_for('main.service_settings', service_id=service_one['id']) not in page
|
||||
assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
# assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
assert url_for('main.view_providers') not in page
|
||||
|
||||
|
||||
@@ -1190,7 +1126,7 @@ def test_menu_manage_service(
|
||||
assert url_for('main.manage_users', service_id=service_one['id']) in page
|
||||
assert url_for('main.service_settings', service_id=service_one['id']) in page
|
||||
|
||||
assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
# assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
|
||||
|
||||
def test_menu_manage_api_keys(
|
||||
@@ -1246,9 +1182,9 @@ def test_menu_all_services_for_platform_admin_user(
|
||||
assert url_for('main.choose_template', service_id=service_one['id']) in page
|
||||
assert url_for('main.manage_users', service_id=service_one['id']) in page
|
||||
assert url_for('main.service_settings', service_id=service_one['id']) in page
|
||||
assert url_for('main.view_notifications', service_id=service_one['id'], message_type='email') in page
|
||||
# assert url_for('main.view_notifications', service_id=service_one['id'], message_type='email') in page
|
||||
assert url_for('main.view_notifications', service_id=service_one['id'], message_type='sms') in page
|
||||
assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
# assert url_for('main.api_keys', service_id=service_one['id']) not in page
|
||||
|
||||
|
||||
def test_route_for_service_permissions(
|
||||
@@ -1332,7 +1268,7 @@ def test_service_dashboard_updates_gets_dashboard_totals(
|
||||
)
|
||||
|
||||
numbers = [number.text.strip() for number in page.find_all('span', class_='big-number-number')]
|
||||
assert '123' in numbers
|
||||
# assert '123' in numbers # email is disabled
|
||||
assert '456' in numbers
|
||||
|
||||
|
||||
@@ -1438,8 +1374,8 @@ def test_get_tuples_of_financial_years():
|
||||
start=2040,
|
||||
end=2041,
|
||||
)) == [
|
||||
('financial year', 2041, 'http://example.com?year=2041', '2041 to 2042'),
|
||||
('financial year', 2040, 'http://example.com?year=2040', '2040 to 2041'),
|
||||
('fiscal year', 2041, 'http://example.com?year=2041', '2041 to 2042'),
|
||||
('fiscal year', 2040, 'http://example.com?year=2040', '2040 to 2041'),
|
||||
]
|
||||
|
||||
|
||||
@@ -1616,12 +1552,10 @@ def test_service_dashboard_shows_usage(
|
||||
assert normalize_spaces(
|
||||
page.select_one('[data-key=usage]').text
|
||||
) == (
|
||||
'Unlimited '
|
||||
'free email allowance '
|
||||
'$29.85 '
|
||||
'spent on text messages'
|
||||
# '$30.00 '
|
||||
# 'spent on letters'
|
||||
'spent on text messages '
|
||||
'0 '
|
||||
'email disabled during SMS pilot'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user