Merge pull request #3439 from alphagov/previous-financial-years

Show 2 previous financial years on usage page
This commit is contained in:
Chris Hill-Scott
2020-05-11 15:15:00 +01:00
committed by GitHub
3 changed files with 13 additions and 13 deletions

View File

@@ -142,8 +142,8 @@ def usage(service_id):
selected_year=year,
years=get_tuples_of_financial_years(
partial(url_for, '.usage', service_id=service_id),
start=current_financial_year - 1,
end=current_financial_year + 1,
start=current_financial_year - 2,
end=current_financial_year,
),
**calculate_usage(yearly_usage,
free_sms_allowance)
@@ -483,5 +483,5 @@ def get_tuples_of_financial_years(
partial_url(year=year),
'{} to {}'.format(year, year + 1),
)
for year in range(start, end + 1)
for year in reversed(range(start, end + 1))
)

View File

@@ -499,9 +499,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) == (
'2018 to 2019 financial year '
'2020 to 2021 financial year '
'2019 to 2020 financial year '
'2020 to 2021 financial year'
'2018 to 2019 financial year'
)
assert normalize_spaces(page.select_one('.pill-selected-item').text) == (
expected_selected

View File

@@ -794,9 +794,9 @@ def test_stats_pages_show_last_3_years(
)
assert normalize_spaces(page.select_one('.pill').text) == (
'2012 to 2013 financial year '
'2014 to 2015 financial year '
'2013 to 2014 financial year '
'2014 to 2015 financial year'
'2012 to 2013 financial year'
)
@@ -952,9 +952,9 @@ def test_usage_page(
nav = page.find('ul', {'class': 'pill', 'role': 'tablist'})
nav_links = nav.find_all('a')
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav.find('li', {'aria-selected': 'true'}).text) == '2011 to 2012 financial year'
assert normalize_spaces(nav_links[1].text) == '2012 to 2013 financial year'
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year'
assert '252,190' in cols[1].text
assert 'Text messages' in cols[1].text
@@ -994,9 +994,9 @@ def test_usage_page_with_letters(
nav = page.find('ul', {'class': 'pill', 'role': 'tablist'})
nav_links = nav.find_all('a')
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav.find('li', {'aria-selected': 'true'}).text) == '2011 to 2012 financial year'
assert normalize_spaces(nav_links[1].text) == '2012 to 2013 financial year'
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year'
assert '252,190' in cols[1].text
assert 'Text messages' in cols[1].text
@@ -1486,8 +1486,8 @@ def test_get_tuples_of_financial_years():
start=2040,
end=2041,
)) == [
('financial year', 2040, 'http://example.com?year=2040', '2040 to 2041'),
('financial year', 2041, 'http://example.com?year=2041', '2041 to 2042'),
('financial year', 2040, 'http://example.com?year=2040', '2040 to 2041'),
]
@@ -1495,7 +1495,7 @@ def test_get_tuples_of_financial_years_defaults_to_2015():
assert 2015 in list(get_tuples_of_financial_years(
lambda year: 'http://example.com?year={}'.format(year),
end=2040,
))[0]
))[-1]
def test_org_breadcrumbs_do_not_show_if_service_has_no_org(