mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Test for filtering a job by notification status
It’s going to be useful to see all the notifications for a job that are failed/delivered/etc. The API seems to support this behaviour already, but it doesn’t seem to be tested. This commit adds some testsfor the DAO and REST layers.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime, timedelta, date
|
||||
import uuid
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -12,7 +13,8 @@ from app.models import (
|
||||
Notification,
|
||||
Job,
|
||||
NotificationStatistics,
|
||||
TemplateStatistics
|
||||
TemplateStatistics,
|
||||
NOTIFICATION_STATUS_TYPES
|
||||
)
|
||||
|
||||
from app.dao.notifications_dao import (
|
||||
@@ -607,6 +609,28 @@ def test_get_all_notifications_for_job(notify_db, notify_db_session, sample_job)
|
||||
_assert_notification_stats(sample_job.service.id, sms_requested=5)
|
||||
|
||||
|
||||
def test_get_all_notifications_for_job_by_status(notify_db, notify_db_session, sample_job):
|
||||
|
||||
notifications = partial(get_notifications_for_job, sample_job.service.id, sample_job.id)
|
||||
|
||||
for status in NOTIFICATION_STATUS_TYPES:
|
||||
sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
service=sample_job.service,
|
||||
template=sample_job.template,
|
||||
job=sample_job,
|
||||
status=status
|
||||
)
|
||||
|
||||
assert len(notifications().items) == len(NOTIFICATION_STATUS_TYPES)
|
||||
|
||||
for status in NOTIFICATION_STATUS_TYPES:
|
||||
assert len(notifications(filter_dict={'status': status}).items) == 1
|
||||
|
||||
assert len(notifications(filter_dict={'status': NOTIFICATION_STATUS_TYPES[:3]}).items) == 3
|
||||
|
||||
|
||||
def test_update_notification(sample_notification, sample_template):
|
||||
assert sample_notification.status == 'sending'
|
||||
sample_notification.status = 'failed'
|
||||
|
||||
Reference in New Issue
Block a user