Add dao method to get notification by reference with tests

This commit is contained in:
Imdad Ahad
2016-12-07 14:08:22 +00:00
parent f02869c1e6
commit d4d733f997
3 changed files with 25 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ from app.dao.notifications_dao import (
dao_update_notification,
delete_notifications_created_more_than_a_week_ago,
get_notification_by_id,
get_notification_by_reference,
get_notification_for_job,
get_notification_billable_unit_count_per_month,
get_notification_with_personalisation,
@@ -616,7 +617,7 @@ def test_save_notification_with_no_job(sample_template, mmg_provider):
assert notification_from_db.status == 'created'
def test_get_notification(sample_notification):
def test_get_notification_by_id(sample_notification):
notification_from_db = get_notification_with_personalisation(
sample_notification.service.id,
sample_notification.id,
@@ -625,6 +626,16 @@ def test_get_notification(sample_notification):
assert sample_notification == notification_from_db
def test_get_notification_by_reference(notify_db, notify_db_session):
notification = sample_notification(notify_db, notify_db_session, client_reference="some-client-ref")
notification_from_db = get_notification_by_reference(
notification.service.id,
notification.client_reference,
key_type=None
)
assert notification == notification_from_db
def test_save_notification_no_job_id(sample_template, mmg_provider):
assert Notification.query.count() == 0
data = _notification_json(sample_template)