add tests for new noti dao function

This commit is contained in:
Leo Hemsted
2017-09-26 12:16:33 +01:00
parent aaadf09562
commit 18ed90158e
2 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
from app.models import (
NOTIFICATION_CREATED,
NOTIFICATION_PENDING,
NOTIFICATION_SENDING,
KEY_TYPE_TEST,
KEY_TYPE_NORMAL
)
from app.dao.notifications_dao import dao_set_created_live_letter_api_notifications_to_pending
from tests.app.db import create_notification
def test_should_only_get_letter_notifications(
sample_letter_notification,
sample_email_notification,
sample_notification
):
ret = dao_set_created_live_letter_api_notifications_to_pending()
assert sample_letter_notification.status == NOTIFICATION_PENDING
assert sample_email_notification.status == NOTIFICATION_CREATED
assert sample_notification.status == NOTIFICATION_CREATED
assert ret == [sample_letter_notification]
def test_should_only_get_created_letters(sample_letter_template):
created_noti = create_notification(sample_letter_template, status=NOTIFICATION_CREATED)
create_notification(sample_letter_template, status=NOTIFICATION_PENDING)
create_notification(sample_letter_template, status=NOTIFICATION_SENDING)
ret = dao_set_created_live_letter_api_notifications_to_pending()
assert ret == [created_noti]
def test_should_only_get_api_letters(sample_letter_template, sample_letter_job):
api_noti = create_notification(sample_letter_template)
job_noti = create_notification(sample_letter_template, job=sample_letter_job)
ret = dao_set_created_live_letter_api_notifications_to_pending()
assert ret == [api_noti]
def test_should_only_get_normal_api_letters(sample_letter_template):
live_noti = create_notification(sample_letter_template, key_type=KEY_TYPE_NORMAL)
test_noti = create_notification(sample_letter_template, key_type=KEY_TYPE_TEST)
ret = dao_set_created_live_letter_api_notifications_to_pending()
assert ret == [live_noti]

View File

@@ -42,7 +42,10 @@ from app.dao.notifications_dao import (
is_delivery_slow_for_provider,
dao_update_notifications_for_job_to_sent_to_dvla,
dao_get_notifications_by_to_field,
dao_created_scheduled_notification, dao_get_scheduled_notifications, set_scheduled_notification_to_processed)
dao_created_scheduled_notification,
dao_get_scheduled_notifications,
set_scheduled_notification_to_processed
)
from app.dao.services_dao import dao_update_service
from tests.app.db import create_notification, create_api_key