mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Adding a filter to exclude test keys for the template monthly usage query.
Added a test.
This commit is contained in:
@@ -312,7 +312,8 @@ def fetch_monthly_template_usage_for_service(start_date, end_date, service_id):
|
||||
FactNotificationStatus.service_id == service_id,
|
||||
FactNotificationStatus.bst_date >= start_date,
|
||||
FactNotificationStatus.bst_date <= end_date,
|
||||
FactNotificationStatus.notification_status != NOTIFICATION_CANCELLED
|
||||
FactNotificationStatus.key_type != KEY_TYPE_TEST,
|
||||
FactNotificationStatus.notification_status != NOTIFICATION_CANCELLED,
|
||||
).group_by(
|
||||
FactNotificationStatus.template_id,
|
||||
Template.name,
|
||||
|
||||
@@ -461,3 +461,21 @@ def test_fetch_monthly_template_usage_for_service_does_not_include_cancelled_sta
|
||||
)
|
||||
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
@freeze_time('2018-03-30 14:00')
|
||||
def test_fetch_monthly_template_usage_for_service_does_not_include_test_notifications(
|
||||
sample_template
|
||||
):
|
||||
create_ft_notification_status(bst_date=date(2018, 3, 1),
|
||||
service=sample_template.service,
|
||||
template=sample_template,
|
||||
notification_status='delivered',
|
||||
key_type='test',
|
||||
count=15)
|
||||
create_notification(template=sample_template, created_at=datetime.utcnow(), status='cancelled')
|
||||
results = fetch_monthly_template_usage_for_service(
|
||||
datetime(2018, 1, 1), datetime(2018, 3, 31), sample_template.service_id
|
||||
)
|
||||
|
||||
assert len(results) == 0
|
||||
|
||||
Reference in New Issue
Block a user