Ignore services that have letters_as_pdf permission

- We don't want to process the letters as a build file for api calls when the service is generating letters as pdf.
This commit is contained in:
Ken Tsang
2017-12-11 16:20:31 +00:00
parent d0fcfa7d0c
commit f42df8af73
2 changed files with 37 additions and 3 deletions

View File

@@ -1,13 +1,15 @@
from app.models import (
Notification,
NOTIFICATION_CREATED,
NOTIFICATION_PENDING,
NOTIFICATION_SENDING,
KEY_TYPE_TEST,
KEY_TYPE_NORMAL
KEY_TYPE_NORMAL,
LETTER_TYPE
)
from app.dao.notifications_dao import dao_set_created_live_letter_api_notifications_to_pending
from tests.app.db import create_notification
from tests.app.db import create_notification, create_service, create_template
def test_should_only_get_letter_notifications(
@@ -23,6 +25,22 @@ def test_should_only_get_letter_notifications(
assert ret == [sample_letter_notification]
def test_should_ignore_letters_as_pdf(
sample_letter_notification,
):
service = create_service(service_permissions=[LETTER_TYPE, 'letters_as_pdf'])
template = create_template(service, template_type=LETTER_TYPE)
create_notification(template)
all_noti = Notification.query.all()
assert len(all_noti) == 2
ret = dao_set_created_live_letter_api_notifications_to_pending()
assert sample_letter_notification.status == NOTIFICATION_PENDING
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)