From f577e91134568b5dc5160078c225b952d8d0c625 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 28 Apr 2017 11:56:12 +0100 Subject: [PATCH 1/2] 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): From 34de722e73e507604d30ce67f7b359c4a200c4a8 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Fri, 28 Apr 2017 13:32:23 +0100 Subject: [PATCH 2/2] Add test to check for sent notification --- tests/app/dao/test_jobs_dao.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/app/dao/test_jobs_dao.py b/tests/app/dao/test_jobs_dao.py index b3598fd7f..f01b631ba 100644 --- a/tests/app/dao/test_jobs_dao.py +++ b/tests/app/dao/test_jobs_dao.py @@ -43,6 +43,7 @@ def test_should_get_all_statuses_for_notifications_associated_with_job( notification(status='technical-failure') notification(status='temporary-failure') notification(status='permanent-failure') + notification(status='sent') results = dao_get_notification_outcomes_for_job(sample_service.id, sample_job.id) assert [(row.count, row.status) for row in results] == [ @@ -53,7 +54,8 @@ def test_should_get_all_statuses_for_notifications_associated_with_job( (1, 'failed'), (1, 'technical-failure'), (1, 'temporary-failure'), - (1, 'permanent-failure') + (1, 'permanent-failure'), + (1, 'sent') ]