From 2aa3e78db212ecde300e944da5be1538d6080425 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Tue, 26 Apr 2022 15:19:24 +0100 Subject: [PATCH] Tidy up monthly usage test assertions The "with_letters" was mostly a duplicate of the one before - no change in test setup - bar the three assertions at the end. Having the assertions in a separate test will help keep the one above manageable as we add more assertions for the annual usage. --- tests/app/main/views/test_dashboard.py | 57 +++++++------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index de47ffde5..4f51a50d0 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1012,22 +1012,9 @@ def test_usage_page( assert '252,190' in cols[1].text assert 'Text messages' in cols[1].text - table = page.find('table').text.strip() - - assert '249,860 free text messages' in table - assert '40 free text messages' in table - assert '960 text messages at 1.65p' in table - assert 'April' in table - assert 'February' in table - assert 'March' in table - assert '£28.99' in table - assert '140 free text messages' in table - assert '£20.91' in table - assert '1,230 text messages at 1.70p' in table - @freeze_time("2012-03-31 12:12:12") -def test_usage_page_with_letters( +def test_usage_page_monthly_breakdown( client_request, service_one, mock_get_usage, @@ -1040,35 +1027,21 @@ def test_usage_page_with_letters( service_id=SERVICE_ONE_ID, ) - mock_get_billable_units.assert_called_once_with(SERVICE_ONE_ID, 2011) - mock_get_usage.assert_called_once_with(SERVICE_ONE_ID, 2011) - mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011) + monthly_breakdown = normalize_spaces(page.find('table').text) - cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'}) - 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 '252,190' in cols[1].text - assert 'Text messages' in cols[1].text - - table = page.find('table').text.strip() - - assert '249,860 free text messages' in table - assert '40 free text messages' in table - assert '960 text messages at 1.65p' in table - assert 'April' in table - assert 'February' in table - assert 'March' in table - assert '£28.99' in table - assert '140 free text messages' in table - assert '£20.91' in table - assert '1,230 text messages at 1.70p' in table - assert '10 second class letters at 31p' in normalize_spaces(table) - assert '5 first class letters at 33p' in normalize_spaces(table) - assert '10 international letters at 84p' in normalize_spaces(table) + assert '249,860 free text messages' in monthly_breakdown + assert '40 free text messages' in monthly_breakdown + assert '960 text messages at 1.65p' in monthly_breakdown + assert 'April' in monthly_breakdown + assert 'February' in monthly_breakdown + assert 'March' in monthly_breakdown + assert '£28.99' in monthly_breakdown + assert '140 free text messages' in monthly_breakdown + assert '£20.91' in monthly_breakdown + assert '1,230 text messages at 1.70p' in monthly_breakdown + assert '10 second class letters at 31p' in monthly_breakdown + assert '5 first class letters at 33p' in monthly_breakdown + assert '10 international letters at 84p' in monthly_breakdown @freeze_time("2012-04-30 12:12:12")