From e8c3a4981235e85b928807ebba67d91edb1ec080 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 5 Mar 2020 14:40:32 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20pluralise=20counts=20of=20one?= =?UTF-8?q?=20on=20org=20usage=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 email sent. 1 free text message sent. --- .../organisations/organisation/index.html | 5 +-- .../views/organisations/test_organisation.py | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/templates/views/organisations/organisation/index.html b/app/templates/views/organisations/organisation/index.html index 9c766a612..7ce3c3dc1 100644 --- a/app/templates/views/organisations/organisation/index.html +++ b/app/templates/views/organisations/organisation/index.html @@ -1,5 +1,6 @@ {% from "components/big-number.html" import big_number %} {% from "components/live-search.html" import live_search %} +{% from "components/message-count-label.html" import message_count_label %} {% from "components/pill.html" import pill %} {% extends "org_template.html" %} @@ -74,7 +75,7 @@
{{ big_number( service.emails_sent, - label='emails sent', + label=message_count_label(service.emails_sent, 'email'), smallest=True ) }}
@@ -89,7 +90,7 @@ {% else %} {{ big_number( service.sms_billable_units, - 'free text messages sent', + 'free {}'.format(message_count_label(service.sms_billable_units, 'sms')), smallest=True ) }} {% endif %} diff --git a/tests/app/main/views/organisations/test_organisation.py b/tests/app/main/views/organisations/test_organisation.py index 1f3777e9d..8085e30ef 100644 --- a/tests/app/main/views/organisations/test_organisation.py +++ b/tests/app/main/views/organisations/test_organisation.py @@ -442,6 +442,38 @@ def test_organisation_services_shows_live_services_and_usage( assert not page.select('.govuk-hint') +@freeze_time("2020-02-20 20:20") +def test_organisation_services_shows_live_services_and_usage_with_count_of_1( + client_request, + mock_get_organisation, + mocker, + active_user_with_permissions, + fake_uuid, +): + mocker.patch( + 'app.organisations_client.get_services_and_usage', + return_value={"services": [ + {'service_id': SERVICE_ONE_ID, 'service_name': '1', 'chargeable_billable_sms': 1, 'emails_sent': 1, + 'free_sms_limit': 250000, 'letter_cost': 0, 'sms_billable_units': 1, 'sms_cost': 0, + 'sms_remainder': None}, + ]} + ) + + client_request.login(active_user_with_permissions) + page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + + usage_rows = page.select('main .govuk-grid-column-one-third') + + # Totals + assert normalize_spaces(usage_rows[0].text) == "Emails 1 sent" + assert normalize_spaces(usage_rows[1].text) == "Text messages £0.00 spent" + assert normalize_spaces(usage_rows[2].text) == "Letters £0.00 spent" + + assert normalize_spaces(usage_rows[3].text) == "1 email sent" + assert normalize_spaces(usage_rows[4].text) == "1 free text message sent" + assert normalize_spaces(usage_rows[5].text) == "£0.00 spent on letters" + + @freeze_time("2020-02-20 20:20") @pytest.mark.parametrize('financial_year, expected_selected', ( (2018, '2018 to 2019 financial year'),