add tests for new sched task

This commit is contained in:
Leo Hemsted
2017-09-26 12:03:06 +01:00
parent b1928b928c
commit aaadf09562
4 changed files with 82 additions and 6 deletions

View File

@@ -325,9 +325,9 @@ def run_letter_jobs():
current_app.logger.info("Queued {} ready letter job ids onto {}".format(len(job_ids), QueueNames.PROCESS_FTP))
@notify_celery.task(name="run-letter-notifications")
@notify_celery.task(name="run-letter-api-notifications")
@statsd(namespace="tasks")
def run_letter_notifications():
def run_letter_api_notifications():
current_time = datetime.utcnow().isoformat()
notifications = dao_set_created_live_letter_api_notifications_to_pending()

View File

@@ -230,8 +230,8 @@ class Config(object):
'schedule': crontab(hour=5, minute=30),
'options': {'queue': QueueNames.PERIODIC}
},
'run-letter-notifications': {
'task': 'run-letter-notifications',
'run-letter-api-notifications': {
'task': 'run-letter-api-notifications',
'schedule': crontab(hour=5, minute=40),
'options': {'queue': QueueNames.PERIODIC}
}

View File

@@ -586,7 +586,7 @@ def dao_set_created_live_letter_api_notifications_to_pending():
the transaction so that if the task is run more than once concurrently, one task will block the other select
from completing until it commits.
"""
return db.session.query(
notifications = db.session.query(
Notification
).filter(
Notification.notification_type == LETTER_TYPE,
@@ -597,7 +597,7 @@ def dao_set_created_live_letter_api_notifications_to_pending():
).all()
for notification in notifications:
notification.notification_status = NOTIFICATION_PENDING
notification.status = NOTIFICATION_PENDING
db.session.add_all(notifications)
db.session.commit()