mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Process responses for letters even after the notification has been deleted.
This will continue to update the notification history for letter notifications. We currently have an issue where the responses to letters from the provider is taking a long time. This is due to the manual nature of their process. Updating the status of the letter will still work if the notification has been purged. Also turned back on the purge letter notification scheduled task.
This commit is contained in:
@@ -9,11 +9,12 @@ from app.exceptions import DVLAException
|
||||
from app.models import (
|
||||
Job,
|
||||
Notification,
|
||||
NotificationHistory,
|
||||
NOTIFICATION_CREATED,
|
||||
NOTIFICATION_DELIVERED,
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_TEMPORARY_FAILURE,
|
||||
NOTIFICATION_TECHNICAL_FAILURE
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
)
|
||||
from app.celery.tasks import (
|
||||
check_billable_units,
|
||||
@@ -59,6 +60,22 @@ def test_update_letter_notifications_statuses_raises_for_invalid_format(notify_a
|
||||
assert 'DVLA response file: {} has an invalid format'.format('foo.txt') in str(e)
|
||||
|
||||
|
||||
def test_update_letter_notification_statuses_when_notification_does_not_exist_updates_notification_history(
|
||||
sample_letter_template,
|
||||
mocker
|
||||
):
|
||||
valid_file = 'ref-foo|Sent|1|Unsorted'
|
||||
mocker.patch('app.celery.tasks.s3.get_s3_file', return_value=valid_file)
|
||||
notification = create_notification(sample_letter_template, reference='ref-foo', status=NOTIFICATION_SENDING,
|
||||
billable_units=1)
|
||||
Notification.query.filter_by(id=notification.id).delete()
|
||||
|
||||
update_letter_notifications_statuses(filename="older_than_7_days.txt")
|
||||
|
||||
updated_history = NotificationHistory.query.filter_by(id=notification.id).one()
|
||||
assert updated_history.status == NOTIFICATION_DELIVERED
|
||||
|
||||
|
||||
def test_update_letter_notifications_statuses_raises_dvla_exception(notify_api, mocker, sample_letter_template):
|
||||
valid_file = 'ref-foo|Failed|1|Unsorted'
|
||||
mocker.patch('app.celery.tasks.s3.get_s3_file', return_value=valid_file)
|
||||
@@ -191,8 +208,7 @@ def test_check_billable_units_when_billable_units_matches_page_count(
|
||||
):
|
||||
mock_logger = mocker.patch('app.celery.tasks.current_app.logger.error')
|
||||
|
||||
notification = create_notification(sample_letter_template, reference='REFERENCE_ABC')
|
||||
notification.billable_units = 1
|
||||
create_notification(sample_letter_template, reference='REFERENCE_ABC', billable_units=1)
|
||||
|
||||
check_billable_units(notification_update)
|
||||
|
||||
@@ -207,8 +223,7 @@ def test_check_billable_units_when_billable_units_does_not_match_page_count(
|
||||
):
|
||||
mock_logger = mocker.patch('app.celery.tasks.current_app.logger.error')
|
||||
|
||||
notification = create_notification(sample_letter_template, reference='REFERENCE_ABC')
|
||||
notification.billable_units = 3
|
||||
notification = create_notification(sample_letter_template, reference='REFERENCE_ABC', billable_units=3)
|
||||
|
||||
check_billable_units(notification_update)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user