diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 5ce62a208..1c5705e48 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -132,7 +132,7 @@ def usage(service_id): units = billing_api_client.get_monthly_usage_for_service(service_id, year) yearly_usage = billing_api_client.get_annual_usage_for_service(service_id, year) more_stats = [] - + try: more_stats = format_monthly_stats_to_list( service_api_client.get_monthly_notification_stats(service_id, year)['data'] @@ -145,7 +145,7 @@ def usage(service_id): # This is all the other months # and we need last year's data more_stats = [month for month in more_stats if month['name'] not in ['October', 'November', 'December']] - except Exception as e: + except Exception: pass return render_template( diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index 916481c82..b2b3961ce 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -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 diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 5146573d1..23ea1db25 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -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'), diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index f63ab2db6..c3b7873ca 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -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' ) diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 39a899167..6893ff492 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -483,11 +483,10 @@ def test_navigation_urls( ] == [ '/services/{}'.format(SERVICE_ONE_ID), '/services/{}/templates'.format(SERVICE_ONE_ID), - # '/services/{}/uploads'.format(SERVICE_ONE_ID), '/services/{}/users'.format(SERVICE_ONE_ID), '/services/{}/usage'.format(SERVICE_ONE_ID), '/services/{}/service-settings'.format(SERVICE_ONE_ID), - '/services/{}/api'.format(SERVICE_ONE_ID), + # '/services/{}/api'.format(SERVICE_ONE_ID), ] diff --git a/tests/app/utils/test_time.py b/tests/app/utils/test_time.py index 89db5f9cc..d2fa56d81 100644 --- a/tests/app/utils/test_time.py +++ b/tests/app/utils/test_time.py @@ -17,7 +17,7 @@ def test_is_less_than_days_ago(date_from_db, expected_result): @pytest.mark.parametrize('datetime_string, financial_year', ( ('2021-01-01T00:00:00+00:00', 2020), # Start of 2021 ('2021-04-01T03:59:59+00:00', 2020), # One minute before midnight (BST) - ('2021-04-01T04:00:00+00:00', 2021), # Midnight (BST) + ('2021-10-01T04:05:00+00:00', 2021), # Midnight (BST) ('2021-12-12T12:12:12+01:00', 2021), # Later in the year )) def test_get_financial_year(datetime_string, financial_year): diff --git a/tests/conftest.py b/tests/conftest.py index 3c699dc1a..77f709860 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2128,7 +2128,7 @@ def mock_get_monthly_template_usage(mocker, service_one, fake_uuid): def _stats(service_id, year): return [{ "template_id": fake_uuid, - "month": 4, + "month": 10, "year": year, "count": 2, "name": 'My first template', @@ -2245,51 +2245,7 @@ def mock_get_monthly_usage_for_service(mocker): 'cost': 15.84, }, { - 'month': 'February', - 'notification_type': 'letter', - 'rate': 0.31, - 'chargeable_units': 10, - 'notifications_sent': 10, - 'postage': 'second', - 'charged_units': 10, - 'free_allowance_used': 0, - 'cost': 3.1, - }, - { - 'month': 'February', - 'notification_type': 'letter', - 'rate': 0.33, - 'chargeable_units': 5, - 'notifications_sent': 5, - 'postage': 'first', - 'charged_units': 5, - 'free_allowance_used': 0, - 'cost': 1.65, - }, - { - 'month': 'February', - 'notification_type': 'letter', - 'rate': 0.55, - 'chargeable_units': 3, - 'notifications_sent': 3, - 'postage': 'europe', - 'charged_units': 3, - 'free_allowance_used': 0, - 'cost': 2.52, - }, - { - 'month': 'February', - 'notification_type': 'letter', - 'rate': 0.84, - 'chargeable_units': 7, - 'notifications_sent': 7, - 'postage': 'rest-of-world', - 'charged_units': 7, - 'free_allowance_used': 0, - 'cost': 5.88, - }, - { - 'month': 'April', + 'month': 'October', 'notification_type': 'sms', 'rate': 0.017, 'chargeable_units': 249860,