mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 07:46:06 -04:00
created dao to get notifications by references
This commit is contained in:
@@ -482,6 +482,13 @@ def dao_get_notifications_by_to_field(service_id, search_term, statuses=None):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@statsd(namespace="dao")
|
||||||
|
def dao_get_notifications_by_reference(references):
|
||||||
|
return Notification.query.filter(
|
||||||
|
Notification.reference.in_(references)
|
||||||
|
).all()
|
||||||
|
|
||||||
|
|
||||||
@statsd(namespace="dao")
|
@statsd(namespace="dao")
|
||||||
def dao_created_scheduled_notification(scheduled_notification):
|
def dao_created_scheduled_notification(scheduled_notification):
|
||||||
db.session.add(scheduled_notification)
|
db.session.add(scheduled_notification)
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ from app.dao.notifications_dao import (
|
|||||||
is_delivery_slow_for_provider,
|
is_delivery_slow_for_provider,
|
||||||
set_scheduled_notification_to_processed,
|
set_scheduled_notification_to_processed,
|
||||||
update_notification_status_by_id,
|
update_notification_status_by_id,
|
||||||
update_notification_status_by_reference
|
update_notification_status_by_reference,
|
||||||
|
dao_get_notifications_by_reference
|
||||||
)
|
)
|
||||||
|
|
||||||
from app.dao.services_dao import dao_update_service
|
from app.dao.services_dao import dao_update_service
|
||||||
@@ -2111,6 +2112,17 @@ def test_dao_update_notifications_by_reference_returns_zero_when_no_notification
|
|||||||
assert updated_count == 0
|
assert updated_count == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_dao_get_notifications_by_reference(sample_template):
|
||||||
|
notification_0 = create_notification(template=sample_template, reference='noref')
|
||||||
|
notification_1 = create_notification(template=sample_template, reference='ref')
|
||||||
|
notification_2 = create_notification(template=sample_template, reference='ref')
|
||||||
|
|
||||||
|
noti = dao_get_notifications_by_reference(['ref'])
|
||||||
|
assert len(noti) == 2
|
||||||
|
assert noti[0].id in [notification_1.id, notification_2.id]
|
||||||
|
assert noti[1].id in [notification_1.id, notification_2.id]
|
||||||
|
|
||||||
|
|
||||||
def test_dao_create_notification_sms_sender_mapping(sample_notification):
|
def test_dao_create_notification_sms_sender_mapping(sample_notification):
|
||||||
sms_sender = create_service_sms_sender(service=sample_notification.service, sms_sender='123456')
|
sms_sender = create_service_sms_sender(service=sample_notification.service, sms_sender='123456')
|
||||||
dao_create_notification_sms_sender_mapping(notification_id=sample_notification.id,
|
dao_create_notification_sms_sender_mapping(notification_id=sample_notification.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user