mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-21 05:32:44 -04:00
Test aggregate_notifications_stats
This commit is contained in:
@@ -293,7 +293,7 @@ def aggregate_notifications_stats(template_statistics):
|
||||
notifications = {
|
||||
template_type: {
|
||||
status: 0 for status in ('requested', 'delivered', 'failed')
|
||||
} for template_type in current_service.TEMPLATE_TYPES
|
||||
} for template_type in ["sms", "email", "letter"]
|
||||
}
|
||||
for stat in template_statistics:
|
||||
notifications[stat["template_type"]]["requested"] += stat["count"]
|
||||
|
||||
@@ -10,7 +10,9 @@ from flask import url_for
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.main.views.dashboard import (
|
||||
aggregate_notifications_stats,
|
||||
aggregate_status_types,
|
||||
aggregate_template_usage,
|
||||
format_monthly_stats_to_list,
|
||||
format_template_stats_to_list,
|
||||
get_dashboard_totals,
|
||||
@@ -44,7 +46,15 @@ stub_template_stats = [
|
||||
'template_name': 'two',
|
||||
'template_id': 'id-2',
|
||||
'status': 'created',
|
||||
'count': 200,
|
||||
'count': 100,
|
||||
'is_precompiled_letter': False
|
||||
},
|
||||
{
|
||||
'template_type': 'email',
|
||||
'template_name': 'two',
|
||||
'template_id': 'id-2',
|
||||
'status': 'technical-failure',
|
||||
'count': 100,
|
||||
'is_precompiled_letter': False
|
||||
},
|
||||
{
|
||||
@@ -1064,9 +1074,7 @@ def test_route_for_service_permissions(
|
||||
|
||||
|
||||
def test_aggregate_template_stats():
|
||||
from app.main.views.dashboard import aggregate_template_usage
|
||||
expected = aggregate_template_usage(copy.deepcopy(stub_template_stats))
|
||||
|
||||
assert len(expected) == 4
|
||||
assert expected[0]['template_name'] == 'four'
|
||||
assert expected[0]['count'] == 400
|
||||
@@ -1086,6 +1094,15 @@ def test_aggregate_template_stats():
|
||||
assert expected[3]['template_type'] == 'sms'
|
||||
|
||||
|
||||
def test_aggregate_notifications_stats():
|
||||
expected = aggregate_notifications_stats(copy.deepcopy(stub_template_stats))
|
||||
assert expected == {
|
||||
"sms": {"requested": 100, "delivered": 50, "failed": 0},
|
||||
"letter": {"requested": 700, "delivered": 700, "failed": 0},
|
||||
"email": {"requested": 200, "delivered": 0, "failed": 100}
|
||||
}
|
||||
|
||||
|
||||
def test_service_dashboard_updates_gets_dashboard_totals(
|
||||
mocker,
|
||||
logged_in_client,
|
||||
|
||||
Reference in New Issue
Block a user