diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 89b2bd1c1..7bec34351 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -742,7 +742,8 @@ def dao_get_letters_to_be_printed(print_run_date): notifications = Notification.query.filter( Notification.created_at < convert_bst_to_utc(last_processing_deadline), Notification.notification_type == LETTER_TYPE, - Notification.status == NOTIFICATION_CREATED + Notification.status == NOTIFICATION_CREATED, + Notification.key_type == KEY_TYPE_NORMAL ).order_by( Notification.created_at ).all() diff --git a/tests/app/celery/test_letters_pdf_tasks.py b/tests/app/celery/test_letters_pdf_tasks.py index efd3f1004..a66045e2b 100644 --- a/tests/app/celery/test_letters_pdf_tasks.py +++ b/tests/app/celery/test_letters_pdf_tasks.py @@ -281,6 +281,15 @@ def test_get_key_and_size_of_letters_to_be_sent_to_print(notify_api, mocker, sam created_at=(datetime.now() - timedelta(minutes=1)).isoformat() ) + # test notification we don't expect to get sent + create_notification( + template=sample_letter_template, + status='created', + reference='ref4', + created_at=(datetime.now() - timedelta(days=1)).isoformat(), + key_type=KEY_TYPE_TEST + ) + mock_s3 = mocker.patch('app.celery.tasks.s3.head_s3_object', side_effect=[ {'ContentLength': 2}, {'ContentLength': 1},