add testing

This commit is contained in:
Beverly Nguyen
2025-01-13 13:39:34 -08:00
parent b2240659ce
commit 88c3da5579
6 changed files with 100 additions and 20 deletions

View File

@@ -211,3 +211,4 @@ class StatisticsType(StrEnum):
REQUESTED = "requested"
DELIVERED = "delivered"
FAILURE = "failure"
PENDING = "pending"

View File

@@ -29,15 +29,18 @@ def format_statistics(statistics, total_notifications=None):
sms_dict = counts[NotificationType.SMS]
delivered_count = sms_dict[StatisticsType.DELIVERED]
failed_count = sms_dict[StatisticsType.FAILURE]
pending_count = total_notifications - (delivered_count + failed_count)
pending_count = max(0, pending_count)
sms_dict[StatisticsType.PENDING] = pending_count
sms_dict[StatisticsType.PENDING] = calculate_pending_stats(
delivered_count, failed_count, total_notifications
)
return counts
def calculate_pending_stats(delivered_count, failed_count, total_notifications):
pending_count = total_notifications - (delivered_count + failed_count)
return max(0, pending_count)
def format_admin_stats(statistics):
counts = create_stats_dict()