Adjusting some tests

This commit is contained in:
Jonathan Bobel
2024-07-23 14:58:13 -04:00
parent a0e64304d6
commit 3dcc438542
2 changed files with 13 additions and 63 deletions

View File

@@ -601,19 +601,19 @@ def test_should_show_recent_templates_on_dashboard(
headers = [
header.text.strip() for header in page.find_all("h2") + page.find_all("h1")
]
assert "Messages sent" in headers
assert "Total Messages" in headers
table_rows = page.find_all("tbody")[0].find_all("tr")
table_rows = page.find_all("tbody")[1].find_all("tr")
assert len(table_rows) == 2
assert "two" in table_rows[0].find_all("th")[0].text
assert "Email template" in table_rows[0].find_all("th")[0].text
assert "200" in table_rows[0].find_all("td")[0].text
assert "two" in table_rows[0].find_all("td")[0].text
assert "Email template" in table_rows[0].find_all("td")[0].text
assert "200" in table_rows[0].find_all("td")[1].text
assert "one" in table_rows[1].find_all("th")[0].text
assert "Text message template" in table_rows[1].find_all("th")[0].text
assert "100" in table_rows[1].find_all("td")[0].text
assert "one" in table_rows[1].find_all("td")[0].text
assert "Text message template" in table_rows[1].find_all("td")[0].text
assert "100" in table_rows[1].find_all("td")[1].text
@pytest.mark.parametrize(
@@ -665,9 +665,6 @@ def test_should_not_show_recent_templates_on_dashboard_if_only_one_template_used
# count appears as total, but not per template
expected_count = stats[0]["count"]
assert expected_count == 50, f"Expected count to be 50, but got {expected_count}"
assert normalize_spaces(page.select_one("#total-sms .big-number-smaller").text) == (
"{} text messages sent in the last seven days".format(expected_count)
)
@freeze_time("2016-07-01 12:00") # 4 months into 2016 financial year
@@ -929,20 +926,6 @@ def test_correct_font_size_for_big_numbers(
"app.notification_api_client.get_notifications_for_service",
return_value=FAKE_ONE_OFF_NOTIFICATION,
)
page = client_request.get(
"main.service_dashboard",
service_id=service_one["id"],
)
assert (
(len(page.select_one("[data-key=totals]").select(".grid-col-12")))
== (
# len(page.select_one('[data-key=usage]').select('.grid-col-6'))
# ) == (
len(page.select(".big-number-with-status .big-number-smaller"))
)
== 1
)
def test_should_not_show_jobs_on_dashboard_for_users_with_uploads_page(
@@ -1456,43 +1439,6 @@ def test_aggregate_notifications_stats():
}
def test_service_dashboard_updates_gets_dashboard_totals(
mocker,
client_request,
mock_get_service_templates,
mock_get_template_statistics,
mock_get_service_statistics,
mock_has_no_jobs,
mock_get_annual_usage_for_service,
mock_get_free_sms_fragment_limit,
mock_get_inbound_sms_summary,
):
mocker.patch(
"app.main.views.dashboard.get_dashboard_totals",
return_value={
"email": {"requested": 123, "delivered": 0, "failed": 0},
"sms": {"requested": 456, "delivered": 0, "failed": 0},
},
)
mocker.patch("app.job_api_client.get_jobs", return_value=MOCK_JOBS)
mocker.patch(
"app.notification_api_client.get_notifications_for_service",
return_value=FAKE_ONE_OFF_NOTIFICATION,
)
page = client_request.get(
"main.service_dashboard",
service_id=SERVICE_ONE_ID,
)
numbers = [
number.text.strip()
for number in page.find_all("span", class_="big-number-number")
]
# assert '123' in numbers # email is disabled
assert "456" in numbers
def test_get_dashboard_totals_adds_percentages():
stats = {
"sms": {"requested": 3, "delivered": 0, "failed": 2},