mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Update process_returned_letters task to insert or update the returned_letter table.
This commit is contained in:
@@ -43,6 +43,7 @@ from app.dao.notifications_dao import (
|
|||||||
dao_get_notification_history_by_reference,
|
dao_get_notification_history_by_reference,
|
||||||
)
|
)
|
||||||
from app.dao.provider_details_dao import get_provider_details_by_notification_type
|
from app.dao.provider_details_dao import get_provider_details_by_notification_type
|
||||||
|
from app.dao.returned_letters_dao import insert_or_update_returned_letters
|
||||||
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
|
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
|
||||||
from app.dao.service_inbound_api_dao import get_service_inbound_api_for_service
|
from app.dao.service_inbound_api_dao import get_service_inbound_api_for_service
|
||||||
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
|
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
|
||||||
@@ -619,6 +620,8 @@ def process_returned_letters_list(notification_references):
|
|||||||
{"status": NOTIFICATION_RETURNED_LETTER}
|
{"status": NOTIFICATION_RETURNED_LETTER}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
insert_or_update_returned_letters(notification_references)
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"Updated {} letter notifications ({} history notifications, from {} references) to returned-letter".format(
|
"Updated {} letter notifications ({} history notifications, from {} references) to returned-letter".format(
|
||||||
updated, updated_history, len(notification_references)
|
updated, updated_history, len(notification_references)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ from app.models import (
|
|||||||
JOB_STATUS_IN_PROGRESS,
|
JOB_STATUS_IN_PROGRESS,
|
||||||
LETTER_TYPE,
|
LETTER_TYPE,
|
||||||
SMS_TYPE,
|
SMS_TYPE,
|
||||||
|
ReturnedLetter
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.app import load_example_csv
|
from tests.app import load_example_csv
|
||||||
@@ -1626,3 +1627,15 @@ def test_process_returned_letters_list_updates_history_if_notification_is_alread
|
|||||||
|
|
||||||
assert [n.status for n in notifications] == ['returned-letter', 'returned-letter']
|
assert [n.status for n in notifications] == ['returned-letter', 'returned-letter']
|
||||||
assert all(n.updated_at for n in notifications)
|
assert all(n.updated_at for n in notifications)
|
||||||
|
|
||||||
|
|
||||||
|
def test_process_returned_letters_populates_returned_letters_table(
|
||||||
|
sample_letter_template
|
||||||
|
):
|
||||||
|
create_notification_history(sample_letter_template, reference='ref1')
|
||||||
|
create_notification_history(sample_letter_template, reference='ref2')
|
||||||
|
|
||||||
|
process_returned_letters_list(['ref1', 'ref2', 'unknown-ref'])
|
||||||
|
|
||||||
|
returned_letters = ReturnedLetter.query.all()
|
||||||
|
assert len(returned_letters) == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user