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