Merge branch 'main' of https://github.com/GSA/notifications-admin into 1423-Sign-in-content-changes-for-login-gov

This commit is contained in:
Jonathan Bobel
2024-04-16 11:10:46 -04:00
6 changed files with 68 additions and 58 deletions

View File

@@ -388,7 +388,7 @@ def test_organization_services_shows_live_services_and_usage(
client_request.login(active_user_with_permissions)
page = client_request.get(".organization_dashboard", org_id=ORGANISATION_ID)
mock.assert_called_once_with(ORGANISATION_ID, 2019)
mock.assert_called_once_with(ORGANISATION_ID, 2020)
services = page.select("main h3")
usage_rows = page.select("main .grid-col-6")
@@ -459,9 +459,9 @@ def test_organization_services_shows_live_services_and_usage_with_count_of_1(
@pytest.mark.parametrize(
("financial_year", "expected_selected"),
[
(2017, "2017 to 2018 fiscal year"),
(2018, "2018 to 2019 fiscal year"),
(2019, "2019 to 2020 fiscal year"),
(2020, "2020 to 2021 fiscal year"),
],
)
def test_organization_services_filters_by_financial_year(
@@ -483,9 +483,9 @@ def test_organization_services_filters_by_financial_year(
)
mock.assert_called_once_with(ORGANISATION_ID, financial_year)
assert normalize_spaces(page.select_one(".pill").text) == (
"2020 to 2021 fiscal year "
"2019 to 2020 fiscal year "
"2018 to 2019 fiscal year "
"2017 to 2018 fiscal year"
"2018 to 2019 fiscal year"
)
assert normalize_spaces(page.select_one(".pill-item--selected").text) == (
expected_selected
@@ -610,7 +610,7 @@ def test_organization_services_links_to_downloadable_report(
assert link_to_report.attrs["href"] == url_for(
".download_organization_usage_report",
org_id=ORGANISATION_ID,
selected_year=2021,
selected_year=2022,
)

View File

@@ -678,12 +678,12 @@ def test_should_show_redirect_from_template_history(
)
@freeze_time("2017-01-01 12:00") # 4 months into 2016 financial year
@freeze_time("2017-01-01 12:00")
@pytest.mark.parametrize(
"extra_args",
[
{},
{"year": "2016"},
{"year": "2017"},
],
)
def test_should_show_monthly_breakdown_of_template_usage(
@@ -695,7 +695,7 @@ def test_should_show_monthly_breakdown_of_template_usage(
"main.template_usage", service_id=SERVICE_ONE_ID, **extra_args
)
mock_get_monthly_template_usage.assert_called_once_with(SERVICE_ONE_ID, 2016)
mock_get_monthly_template_usage.assert_called_once_with(SERVICE_ONE_ID, 2017)
table_rows = page.select("tbody tr")
@@ -703,9 +703,22 @@ def test_should_show_monthly_breakdown_of_template_usage(
"My first template " "Text message template " "2"
)
assert len(table_rows) == len(["October"])
assert len(table_rows) == len(["January"])
# October is the only month with data, thus it's not in the list.
assert len(page.select(".table-no-data")) == len(
["November", "December", "January"]
[
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"November",
"December",
]
)
@@ -748,9 +761,9 @@ def test_stats_pages_show_last_3_years(
)
assert normalize_spaces(page.select_one(".pill").text) == (
"2015 to 2016 fiscal year "
"2014 to 2015 fiscal year "
"2013 to 2014 fiscal year "
"2012 to 2013 fiscal year"
"2013 to 2014 fiscal year"
)
@@ -965,18 +978,18 @@ def test_usage_page(
service_id=SERVICE_ONE_ID,
)
mock_get_monthly_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2011)
mock_get_annual_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2011)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011)
mock_get_monthly_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2012)
mock_get_annual_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2012)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID)
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 fiscal year"
== "2012 to 2013 fiscal year"
)
assert normalize_spaces(unselected_nav_links[0].text) == "2010 to 2011 fiscal year"
assert normalize_spaces(unselected_nav_links[1].text) == "2009 to 2010 fiscal year"
assert normalize_spaces(unselected_nav_links[0].text) == "2011 to 2012 fiscal year"
assert normalize_spaces(unselected_nav_links[1].text) == "2010 to 2011 fiscal year"
annual_usage = page.find_all("div", {"class": "keyline-block"})
@@ -1043,6 +1056,7 @@ def test_usage_page_monthly_breakdown(
page = client_request.get("main.usage", service_id=SERVICE_ONE_ID)
monthly_breakdown = normalize_spaces(page.find("table").text)
assert "January" in monthly_breakdown
assert "October" in monthly_breakdown
assert "February" in monthly_breakdown
assert "March" in monthly_breakdown
@@ -1051,8 +1065,8 @@ def test_usage_page_monthly_breakdown(
@pytest.mark.parametrize(
("now", "expected_number_of_months"),
[
(freeze_time("2017-03-31 11:09:00.061258"), 6),
(freeze_time("2017-01-01 11:09:00.061258"), 4),
(freeze_time("2017-03-31 11:09:00.061258"), 12),
(freeze_time("2017-01-01 11:09:00.061258"), 12),
],
)
def test_usage_page_monthly_breakdown_shows_months_so_far(
@@ -1112,7 +1126,7 @@ def test_usage_page_with_year_argument(
)
mock_get_monthly_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2000)
mock_get_annual_usage_for_service.assert_called_once_with(SERVICE_ONE_ID, 2000)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2000)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID)
mock_get_monthly_notification_stats.assert_called_with(SERVICE_ONE_ID, 2000)
@@ -1147,7 +1161,7 @@ def test_future_usage_page(
mock_get_annual_usage_for_service_in_future.assert_called_once_with(
SERVICE_ONE_ID, 2014
)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2014)
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID)
mock_get_monthly_notification_stats.assert_called_with(SERVICE_ONE_ID, 2014)
@@ -1378,7 +1392,9 @@ def test_route_for_service_permissions(
mock_has_no_jobs,
mock_get_template_statistics,
mock_get_service_statistics,
mock_get_monthly_usage_for_service,
mock_get_annual_usage_for_service,
mock_create_or_update_free_sms_fragment_limit,
mock_get_free_sms_fragment_limit,
mock_get_inbound_sms_summary,
):

View File

@@ -20,10 +20,10 @@ def test_is_less_than_days_ago(date_from_db, expected_result):
@pytest.mark.parametrize(
("datetime_string", "financial_year"),
[
("2021-01-01T00:00:00+00:00", 2020), # Start of 2021
("2021-04-01T03:59:59+00:00", 2020), # One minute before midnight (BST)
("2021-10-01T04:05:00+00:00", 2021), # Midnight (BST)
("2021-12-12T12:12:12+01:00", 2021), # Later in the year
("2021-01-01T00:00:00+00:00", 2021), # Start of 2021
("2021-04-01T03:59:59+00:00", 2021), # One minute before midnight (BST)
("2021-10-01T04:05:00+00:00", 2022), # Midnight (BST)
("2021-12-12T12:12:12+01:00", 2022), # Later in the year
],
)
def test_get_financial_year(datetime_string, financial_year):