set letter notifications to pending while notify-ftp does its stuff

this means that if the task is accidentally ran twice (eg we autoscale
notify-celery-worker-beat to 2), it won't send letters twice.

Additionally, update some function names and config variables to make
it clear that they are referring to letter jobs, rather than all letter
content
This commit is contained in:
Leo Hemsted
2017-09-15 17:46:08 +01:00
parent f61ccd8ff0
commit 7dd3c1df5a
7 changed files with 81 additions and 21 deletions

View File

@@ -40,7 +40,7 @@ from app.dao.notifications_dao import (
dao_delete_notifications_and_history_by_id,
dao_timeout_notifications,
is_delivery_slow_for_provider,
dao_update_notifications_sent_to_dvla,
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)
@@ -1713,11 +1713,11 @@ def test_slow_provider_delivery_does_not_return_for_standard_delivery_time(
assert not slow_delivery
def test_dao_update_notifications_sent_to_dvla(notify_db, notify_db_session, sample_letter_template):
def test_dao_update_notifications_for_job_to_sent_to_dvla(notify_db, notify_db_session, sample_letter_template):
job = sample_job(notify_db=notify_db, notify_db_session=notify_db_session, template=sample_letter_template)
notification = create_notification(template=sample_letter_template, job=job)
updated_count = dao_update_notifications_sent_to_dvla(job_id=job.id, provider='some provider')
updated_count = dao_update_notifications_for_job_to_sent_to_dvla(job_id=job.id, provider='some provider')
assert updated_count == 1
updated_notification = Notification.query.get(notification.id)
@@ -1732,7 +1732,7 @@ def test_dao_update_notifications_sent_to_dvla(notify_db, notify_db_session, sam
assert history.updated_at
def test_dao_update_notifications_sent_to_dvla_does_update_history_if_test_key(sample_letter_job):
def test_dao_update_notifications_for_job_to_sent_to_dvla_does_update_history_if_test_key(sample_letter_job):
api_key = create_api_key(sample_letter_job.service, key_type=KEY_TYPE_TEST)
notification = create_notification(
sample_letter_job.template,
@@ -1740,7 +1740,10 @@ def test_dao_update_notifications_sent_to_dvla_does_update_history_if_test_key(s
api_key=api_key
)
updated_count = dao_update_notifications_sent_to_dvla(job_id=sample_letter_job.id, provider='some provider')
updated_count = dao_update_notifications_for_job_to_sent_to_dvla(
job_id=sample_letter_job.id,
provider='some provider'
)
assert updated_count == 1
updated_notification = Notification.query.get(notification.id)