From f577e91134568b5dc5160078c225b952d8d0c625 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 28 Apr 2017 11:56:12 +0100 Subject: [PATCH] treat sent as delivered in detailed service api this is for when we fetch the large blue numbers for viewing notifications for an entire service --- app/service/statistics.py | 2 +- tests/app/service/test_statistics.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/service/statistics.py b/app/service/statistics.py index b9cd985f2..8ebf8434b 100644 --- a/app/service/statistics.py +++ b/app/service/statistics.py @@ -48,7 +48,7 @@ def create_zeroed_stats_dicts(): def _update_statuses_from_row(update_dict, row): update_dict['requested'] += row.count - if row.status == 'delivered': + if row.status in ('delivered', 'sent'): update_dict['delivered'] += row.count elif row.status in ('failed', 'technical-failure', 'temporary-failure', 'permanent-failure'): update_dict['failed'] += row.count diff --git a/tests/app/service/test_statistics.py b/tests/app/service/test_statistics.py index fd686be18..9c35ad9c7 100644 --- a/tests/app/service/test_statistics.py +++ b/tests/app/service/test_statistics.py @@ -30,6 +30,11 @@ StatsRow = collections.namedtuple('row', ('notification_type', 'status', 'count' StatsRow('email', 'temporary-failure', 1), StatsRow('email', 'permanent-failure', 1), ], [4, 0, 4], [0, 0, 0], [0, 0, 0]), + 'convert_sent_to_delivered': ([ + StatsRow('sms', 'sending', 1), + StatsRow('sms', 'delivered', 1), + StatsRow('sms', 'sent', 1), + ], [0, 0, 0], [3, 2, 0], [0, 0, 0]), }) def test_format_statistics(stats, email_counts, sms_counts, letter_counts):