From 38cfee639084103bf2fca3dc8521b119e7c72430 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Mon, 15 Mar 2021 18:04:01 +0000 Subject: [PATCH] Rename usage report to billing report Because only services with bills to pay are included, and we started including billing details. Also rename endpoints and file names to match this. --- app/main/views/platform_admin.py | 8 ++++---- app/navigation.py | 2 +- app/notify_client/billing_api_client.py | 4 ++-- ...r_all_services.html => get-billing-report.html} | 4 ++-- app/templates/views/platform-admin/reports.html | 2 +- tests/app/main/views/test_platform_admin.py | 14 +++++++------- 6 files changed, 17 insertions(+), 17 deletions(-) rename app/templates/views/platform-admin/{usage_for_all_services.html => get-billing-report.html} (91%) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index 430c11f49..8c487857c 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -274,7 +274,7 @@ def notifications_sent_by_service(): @main.route("/platform-admin/reports/usage-for-all-services", methods=['GET', 'POST']) @user_is_platform_admin -def usage_for_all_services(): +def get_billing_report(): form = RequiredDateFilterForm() if form.validate_on_submit(): @@ -286,7 +286,7 @@ def usage_for_all_services(): "contact_names", "contact_email_addresses", "billing_reference" ] - result = billing_api_client.get_usage_for_all_services(start_date, end_date) + result = billing_api_client.get_data_for_billing_report(start_date, end_date) rows = [ [ r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"], @@ -299,13 +299,13 @@ def usage_for_all_services(): if rows: return Spreadsheet.from_rows([headers] + rows).as_csv_data, 200, { 'Content-Type': 'text/csv; charset=utf-8', - 'Content-Disposition': 'attachment; filename="Usage for all services from {} to {}.csv"'.format( + 'Content-Disposition': 'attachment; filename="Billing Report from {} to {}.csv"'.format( start_date, end_date ) } else: flash('No results for dates') - return render_template('views/platform-admin/usage_for_all_services.html', form=form) + return render_template('views/platform-admin/get-billing-report.html', form=form) @main.route("/platform-admin/complaints") diff --git a/app/navigation.py b/app/navigation.py index 9c3abef18..a6145c95a 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -89,7 +89,7 @@ class HeaderNavigation(Navigation): 'live_services', 'live_services_csv', 'notifications_sent_by_service', - 'usage_for_all_services', + 'get_billing_report', 'organisations', 'platform_admin', 'platform_admin_list_complaints', diff --git a/app/notify_client/billing_api_client.py b/app/notify_client/billing_api_client.py index 849716b55..ed083692e 100644 --- a/app/notify_client/billing_api_client.py +++ b/app/notify_client/billing_api_client.py @@ -34,8 +34,8 @@ class BillingAPIClient(NotifyAdminAPIClient): data=data ) - def get_usage_for_all_services(self, start_date, end_date): - return self.get(url='/platform-stats/usage-for-all-services', + def get_data_for_billing_report(self, start_date, end_date): + return self.get(url='/platform-stats/data-for-billing-report', params={ 'start_date': str(start_date), 'end_date': str(end_date), diff --git a/app/templates/views/platform-admin/usage_for_all_services.html b/app/templates/views/platform-admin/get-billing-report.html similarity index 91% rename from app/templates/views/platform-admin/usage_for_all_services.html rename to app/templates/views/platform-admin/get-billing-report.html index a99465dfe..068122389 100644 --- a/app/templates/views/platform-admin/usage_for_all_services.html +++ b/app/templates/views/platform-admin/get-billing-report.html @@ -2,13 +2,13 @@ {% from "components/form.html" import form_wrapper %} {% block per_page_title %} - Usage for all services + Billing Report {% endblock %} {% block platform_admin_content %}

- Usage for all services + Billing Report

{% call form_wrapper() %} diff --git a/app/templates/views/platform-admin/reports.html b/app/templates/views/platform-admin/reports.html index da3b94cd4..f258eca20 100644 --- a/app/templates/views/platform-admin/reports.html +++ b/app/templates/views/platform-admin/reports.html @@ -17,6 +17,6 @@ Monthly notification statuses for live services

- Usage for all services + Billing Report

{% endblock %} diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py index 821383baa..c1ac2bff6 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -832,13 +832,13 @@ def test_get_notifications_sent_by_service_validates_form(mocker, client_request assert mock_get_stats_from_api.called is False -def test_usage_for_all_services_when_no_results_for_date(client_request, platform_admin_user, mocker): +def test_get_billing_report_when_no_results_for_date(client_request, platform_admin_user, mocker): client_request.login(platform_admin_user) - mocker.patch("app.main.views.platform_admin.billing_api_client.get_usage_for_all_services", + mocker.patch("app.main.views.platform_admin.billing_api_client.get_data_for_billing_report", return_value=[]) - page = client_request.post('main.usage_for_all_services', + page = client_request.post('main.get_billing_report', _expected_status=200, _data={'start_date': '2019-01-01', 'end_date': '2019-03-31'}) @@ -846,9 +846,9 @@ def test_usage_for_all_services_when_no_results_for_date(client_request, platfor assert normalize_spaces(error.text) == 'No results for dates' -def test_usage_for_all_services_when_calls_api_and_download_data(platform_admin_client, mocker): +def test_get_billing_report_when_calls_api_and_download_data(platform_admin_client, mocker): mocker.patch( - "app.main.views.platform_admin.billing_api_client.get_usage_for_all_services", + "app.main.views.platform_admin.billing_api_client.get_data_for_billing_report", return_value=[{ 'letter_breakdown': '6 second class letters at 45p\n2 first class letters at 35p\n', 'letter_cost': 3.4, @@ -865,13 +865,13 @@ def test_usage_for_all_services_when_calls_api_and_download_data(platform_admin_ }] ) - response = platform_admin_client.post(url_for('main.usage_for_all_services'), + response = platform_admin_client.post(url_for('main.get_billing_report'), data={'start_date': '2019-01-01', 'end_date': '2019-03-31'}) assert response.status_code == 200 assert response.content_type == 'text/csv; charset=utf-8' assert response.headers['Content-Disposition'] == ( - 'attachment; filename="Usage for all services from {} to {}.csv"'.format('2019-01-01', '2019-03-31') + 'attachment; filename="Billing Report from {} to {}.csv"'.format('2019-01-01', '2019-03-31') ) assert response.get_data(as_text=True) == (