fixed pytesting

This commit is contained in:
Beverly Nguyen
2024-08-14 15:47:50 -07:00
parent c2cb8e8f85
commit 6175bfb2fb
3 changed files with 18 additions and 7 deletions

View File

@@ -94,7 +94,7 @@ def service_dashboard(service_id):
@main.route("/daily_stats.json")
def get_daily_stats():
service_id = session.get('service_id')
service_id = session.get("service_id")
date_range = get_stats_date_range()
stats = service_api_client.get_service_notification_statistics_by_day(
@@ -105,7 +105,7 @@ def get_daily_stats():
@main.route("/daily_stats_by_user.json")
def get_daily_stats_by_user():
service_id = session.get('service_id')
service_id = session.get("service_id")
date_range = get_stats_date_range()
user_id = current_user.id
stats = service_api_client.get_user_service_notification_statistics_by_day(

View File

@@ -21,7 +21,10 @@ MOCK_JOBS = {
"scheduled_for": None,
"service": "21b3ee3d-1cb0-4666-bfa0-9c5ac26d3fe3",
"service_name": {"name": "Mock Texting Service"},
"statistics": [{"count": 1, "status": "delivered"}, {"count": 5, "status": "failed"}],
"statistics": [
{"count": 1, "status": "delivered"},
{"count": 5, "status": "failed"},
],
"template": "6a456418-498c-4c86-b0cd-9403c14a216c",
"template_name": "Mock Template Name",
"template_type": "sms",
@@ -63,7 +66,15 @@ def test_all_activity(
assert table is not None, "Table not found in the response"
headers = [th.get_text(strip=True) for th in table.find_all("th")]
expected_headers = ["Job ID#", "Template", "Time sent", "Sender", "Report", "Delivered", "Failed"]
expected_headers = [
"Job ID#",
"Template",
"Time sent",
"Sender",
"Report",
"Delivered",
"Failed",
]
assert (
headers == expected_headers
@@ -103,9 +114,7 @@ def test_all_activity(
), f"Expected delivered count '1', but got '{delivered_cell}'"
failed_cell = cells[6].get_text(strip=True)
assert (
failed_cell == "5"
), f"Expected failed count '5', but got '{failed_cell}'"
assert failed_cell == "5", f"Expected failed count '5', but got '{failed_cell}'"
mock_get_page_of_jobs.assert_called_with(SERVICE_ONE_ID, page=current_page)

View File

@@ -96,6 +96,8 @@ EXCLUDED_ENDPOINTS = tuple(
"get_users_report",
"get_daily_volumes",
"get_daily_sms_provider_volumes",
"get_daily_stats",
"get_daily_stats_by_user",
"get_volumes_by_service",
"get_example_csv",
"get_notifications_as_json",