From 5511f15ae83b1a07540bee7a5aec1ab57320500d Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Wed, 27 Apr 2022 17:08:44 +0100 Subject: [PATCH] Add missing dashboard test for zero SMS cost --- tests/app/main/views/test_dashboard.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 3e87f9c7f..5e6a6d2a7 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1890,3 +1890,30 @@ def test_service_dashboard_shows_usage( '£30.00 ' 'spent on letters' ) + + +def test_service_dashboard_shows_free_allowance( + mocker, + client_request, + service_one, + mock_get_service_templates, + mock_get_template_statistics, + mock_has_no_jobs, + mock_get_free_sms_fragment_limit, + mock_get_returned_letter_statistics_with_no_returned_letters, +): + mocker.patch('app.billing_api_client.get_service_usage', return_value=[ + { + "notification_type": "sms", + "chargeable_units": 1000, + "charged_units": 0, + "rate": 0.0165, + "cost": 0 + } + ]) + + page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID) + + usage_text = normalize_spaces(page.select_one('[data-key=usage]').text) + assert 'spent on text messages' not in usage_text + assert '249,000 free text messages left' in usage_text