mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 08:44:23 -04:00
Merge branch 'main' of https://github.com/GSA/notifications-admin into e2e-test-invite-to-service
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -2545,11 +2545,19 @@ def test_send_files_by_email_contact_details_does_not_update_invalid_contact_det
|
||||
@pytest.mark.parametrize(
|
||||
("endpoint", "permissions", "expected_p"),
|
||||
[
|
||||
("main.service_set_auth_type", [], ("Text message code")),
|
||||
(
|
||||
"main.service_set_auth_type",
|
||||
[],
|
||||
(
|
||||
"Your username, password, and multi-factor authentication options are handled by Login.gov."
|
||||
),
|
||||
),
|
||||
(
|
||||
"main.service_set_auth_type",
|
||||
["email_auth"],
|
||||
("Email link or text message code"),
|
||||
(
|
||||
"Your username, password, and multi-factor authentication options are handled by Login.gov."
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -222,8 +222,7 @@ def test_if_existing_user_accepts_twice_they_redirect_to_sign_in(
|
||||
) == (
|
||||
"You need to sign in again",
|
||||
# TODO: Improve this given Login.gov configuration.
|
||||
# "We signed you out because you have not used Notify for a while.",
|
||||
"You have left to use Login.gov to sign in",
|
||||
"We signed you out because you have not used Notify for a while.",
|
||||
)
|
||||
# We don’t let people update `email_access_validated_at` using an
|
||||
# already-accepted invite
|
||||
@@ -338,8 +337,7 @@ def test_existing_user_of_service_get_redirected_to_signin(
|
||||
) == (
|
||||
"You need to sign in again",
|
||||
# TODO: Improve this given Login.gov configuration.
|
||||
# "We signed you out because you have not used Notify for a while.",
|
||||
"You have left to use Login.gov to sign in",
|
||||
"We signed you out because you have not used Notify for a while.",
|
||||
)
|
||||
assert mock_accept_invite.call_count == 1
|
||||
|
||||
@@ -429,8 +427,7 @@ def test_existing_signed_out_user_accept_invite_redirects_to_sign_in(
|
||||
) == (
|
||||
"You need to sign in again",
|
||||
# TODO: Improve this given Login.gov configuration.
|
||||
# "We signed you out because you have not used Notify for a while.",
|
||||
"You have left to use Login.gov to sign in",
|
||||
"We signed you out because you have not used Notify for a while.",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
):
|
||||
|
||||
@@ -12,40 +12,21 @@ def test_render_sign_in_template_for_new_user(client_request):
|
||||
client_request.logout()
|
||||
page = client_request.get("main.sign_in")
|
||||
assert normalize_spaces(page.select_one("h1").text) == "Sign in"
|
||||
assert normalize_spaces(page.select("label")[0].text) == "Email address"
|
||||
assert page.select_one("#email_address").get("value") is None
|
||||
assert page.select_one("#email_address")["autocomplete"] == "email"
|
||||
assert normalize_spaces(page.select("label")[1].text) == "Password"
|
||||
assert page.select_one("#password").get("value") is None
|
||||
assert page.select_one("#password")["autocomplete"] == "current-password"
|
||||
# Removing for the pilot
|
||||
# assert page.select('main a')[0].text == 'create one now'
|
||||
# assert page.select('main a')[0]['href'] == url_for('main.register')
|
||||
assert (
|
||||
page.select("main p")[0].text
|
||||
== "Access your Notify.gov account by signing in with Login.gov:"
|
||||
)
|
||||
# TODO: Fix this test to be less brittle! If the Login.gov link is enabled,
|
||||
# then these indices need to be 1 instead of 0.
|
||||
# Currently it's not enabled for the test or production environments.
|
||||
assert page.select("main a")[1].text == "Forgot your password?"
|
||||
assert page.select("main a")[1]["href"] == url_for("main.forgot_password")
|
||||
assert page.select("main a")[0].text == "Sign in with Login.gov"
|
||||
assert page.select("main a")[1].text == "Create Login.gov account"
|
||||
|
||||
# TODO: We'll have to adjust this depending on whether Login.gov is
|
||||
# enabled or not; fix this in the future.
|
||||
assert "Sign in again" not in normalize_spaces(page.text)
|
||||
|
||||
|
||||
def test_render_sign_in_template_with_next_link_for_password_reset(client_request):
|
||||
client_request.logout()
|
||||
page = client_request.get(
|
||||
"main.sign_in",
|
||||
_optional_args=f"?next=/services/{SERVICE_ONE_ID}/templates",
|
||||
_test_page_title=False,
|
||||
)
|
||||
forgot_password_link = page.find("a", class_="usa-link")
|
||||
assert forgot_password_link.text == "Forgot your password?"
|
||||
assert forgot_password_link["href"] == url_for(
|
||||
"main.forgot_password", next=f"/services/{SERVICE_ONE_ID}/templates"
|
||||
)
|
||||
|
||||
|
||||
def test_reformat_keystring():
|
||||
orig = "-----BEGIN PRIVATE KEY----- blah blah blah -----END PRIVATE KEY-----"
|
||||
expected = """-----BEGIN PRIVATE KEY-----
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -2330,6 +2330,8 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
||||
"app.billing_api_client.create_or_update_free_sms_fragment_limit", autospec=True
|
||||
)
|
||||
|
||||
mocker.patch("app.billing_api_client.get_monthly_usage_for_service", autospec=True)
|
||||
|
||||
class ClientRequest:
|
||||
@staticmethod
|
||||
@contextmanager
|
||||
|
||||
Reference in New Issue
Block a user