mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
fix test
This commit is contained in:
@@ -276,7 +276,8 @@ def get_recent_notifications_for_job(
|
|||||||
stmt = select(Notification).where(
|
stmt = select(Notification).where(
|
||||||
Notification.service_id == service_id,
|
Notification.service_id == service_id,
|
||||||
Notification.job_id == job_id,
|
Notification.job_id == job_id,
|
||||||
Notification.status in [NotificationStatus.FAILED, NotificationStatus.DELIVERED],
|
Notification.status
|
||||||
|
in [NotificationStatus.FAILED, NotificationStatus.DELIVERED],
|
||||||
)
|
)
|
||||||
stmt = _filter_query(stmt, filter_dict)
|
stmt = _filter_query(stmt, filter_dict)
|
||||||
stmt = stmt.order_by(desc(Notification.job_row_number))
|
stmt = stmt.order_by(desc(Notification.job_row_number))
|
||||||
|
|||||||
@@ -694,20 +694,14 @@ def test_get_all_notifications_for_job(sample_job):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_recent_notifications_for_job(sample_job):
|
def test_get_recent_notifications_for_job(sample_job):
|
||||||
for x in range(0, 5):
|
|
||||||
try:
|
for status in NotificationStatus:
|
||||||
n = create_notification(template=sample_job.template, job=sample_job)
|
create_notification(template=sample_job.template, job=sample_job, status=status)
|
||||||
if x == 0:
|
|
||||||
n.status = NotificationStatus.DELIVERED
|
|
||||||
elif x in [1, 2]:
|
|
||||||
n.status = NotificationStatus.FAILED
|
|
||||||
except IntegrityError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
notifications_from_db = get_recent_notifications_for_job(
|
notifications_from_db = get_recent_notifications_for_job(
|
||||||
sample_job.service.id, sample_job.id
|
sample_job.service.id, sample_job.id
|
||||||
).items
|
).items
|
||||||
assert len(notifications_from_db) == 3
|
assert len(notifications_from_db) == 2
|
||||||
print(notifications_from_db)
|
print(notifications_from_db)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -503,6 +503,11 @@ def test_get_recent_notifications_for_job_in_reverse_order_of_job_number(
|
|||||||
notification_1 = create_notification(job=main_job, to_field="1", job_row_number=1)
|
notification_1 = create_notification(job=main_job, to_field="1", job_row_number=1)
|
||||||
notification_2 = create_notification(job=main_job, to_field="2", job_row_number=2)
|
notification_2 = create_notification(job=main_job, to_field="2", job_row_number=2)
|
||||||
notification_3 = create_notification(job=main_job, to_field="3", job_row_number=3)
|
notification_3 = create_notification(job=main_job, to_field="3", job_row_number=3)
|
||||||
|
|
||||||
|
count = 1
|
||||||
|
for status in NotificationStatus:
|
||||||
|
create_notification(job=main_job, to_field=str(count), status=status)
|
||||||
|
count = count + 1
|
||||||
create_notification(job=another_job)
|
create_notification(job=another_job)
|
||||||
|
|
||||||
resp = admin_request.get(
|
resp = admin_request.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user