mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Send zendesk ticket when services found with high failure rates
This commit is contained in:
@@ -6,12 +6,13 @@ from freezegun import freeze_time
|
||||
import pytest
|
||||
|
||||
from app.service.statistics import (
|
||||
format_admin_stats,
|
||||
format_statistics,
|
||||
add_monthly_notification_status_stats,
|
||||
create_empty_monthly_notification_status_stats_dict,
|
||||
create_stats_dict,
|
||||
create_zeroed_stats_dicts,
|
||||
create_empty_monthly_notification_status_stats_dict,
|
||||
add_monthly_notification_status_stats
|
||||
format_admin_stats,
|
||||
format_statistics,
|
||||
get_rate_of_permanent_failures_for_service
|
||||
)
|
||||
|
||||
StatsRow = collections.namedtuple('row', ('notification_type', 'status', 'count'))
|
||||
@@ -73,6 +74,32 @@ def test_format_statistics(stats, email_counts, sms_counts, letter_counts):
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.idparametrize("statistics, expected_result", {
|
||||
'counts_rate_for_sms': ([
|
||||
StatsRow('sms', 'permanent-failure', 100),
|
||||
StatsRow('sms', 'delivered', 300),
|
||||
], 0.25),
|
||||
'ignores_other_notification_types': ([
|
||||
StatsRow('sms', 'permanent-failure', 100),
|
||||
StatsRow('sms', 'delivered', 300),
|
||||
StatsRow('email', 'delivered', 300),
|
||||
StatsRow('letter', 'created', 300),
|
||||
], 0.25),
|
||||
'only_counts_permanent_failure_as_failed': ([
|
||||
StatsRow('sms', 'permanent-failure', 100),
|
||||
StatsRow('sms', 'temporary-failure', 100),
|
||||
StatsRow('sms', 'delivered', 300),
|
||||
], 0.2),
|
||||
'below_threshold': ([
|
||||
StatsRow('sms', 'permanent-failure', 5),
|
||||
StatsRow('sms', 'delivered', 3),
|
||||
], 0),
|
||||
})
|
||||
def test_get_rate_of_permanent_failures_for_service(statistics, expected_result):
|
||||
rate = get_rate_of_permanent_failures_for_service(statistics)
|
||||
assert rate == expected_result
|
||||
|
||||
|
||||
def test_create_zeroed_stats_dicts():
|
||||
assert create_zeroed_stats_dicts() == {
|
||||
'sms': {'requested': 0, 'delivered': 0, 'failed': 0},
|
||||
|
||||
Reference in New Issue
Block a user