diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 96b07ed34..6d09fa785 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -51,7 +51,7 @@ def process_job(job_id): db_template = dao_get_template_by_id(job.template_id, job.template_version) - TemplateClass = get_template_class(db_template) + TemplateClass = get_template_class(db_template.template_type) template = TemplateClass(db_template.__dict__) for row_number, recipient, personalisation in RecipientCSV( @@ -266,10 +266,10 @@ def handle_exception(task, notification, notification_id, exc): current_app.logger.exception('Retry' + retry_msg) -def get_template_class(template): - if template.template_type == SMS_TYPE: +def get_template_class(template_type): + if template_type == SMS_TYPE: return SMSMessageTemplate - elif template.template_type in (EMAIL_TYPE, LETTER_TYPE): + elif template_type in (EMAIL_TYPE, LETTER_TYPE): # since we don't need rendering capabilities (we only need to extract placeholders) both email and letter can # use the same base template return WithSubjectTemplate diff --git a/app/config.py b/app/config.py index 8d10051ef..759d2af43 100644 --- a/app/config.py +++ b/app/config.py @@ -167,8 +167,9 @@ class Development(Config): SQLALCHEMY_ECHO = False CELERY_QUEUES = Config.CELERY_QUEUES + [ Queue('db-sms', Exchange('default'), routing_key='db-sms'), - Queue('send-sms', Exchange('default'), routing_key='send-sms'), Queue('db-email', Exchange('default'), routing_key='db-email'), + Queue('db-letter', Exchange('default'), routing_key='db-letter'), + Queue('send-sms', Exchange('default'), routing_key='send-sms'), Queue('send-email', Exchange('default'), routing_key='send-email'), Queue('research-mode', Exchange('default'), routing_key='research-mode') ] @@ -186,8 +187,9 @@ class Test(Config): STATSD_PORT = 1000 CELERY_QUEUES = Config.CELERY_QUEUES + [ Queue('db-sms', Exchange('default'), routing_key='db-sms'), - Queue('send-sms', Exchange('default'), routing_key='send-sms'), Queue('db-email', Exchange('default'), routing_key='db-email'), + Queue('db-letter', Exchange('default'), routing_key='db-letter'), + Queue('send-sms', Exchange('default'), routing_key='send-sms'), Queue('send-email', Exchange('default'), routing_key='send-email'), Queue('research-mode', Exchange('default'), routing_key='research-mode') ] diff --git a/manifest-delivery-worker-database.yml b/manifest-delivery-worker-database.yml index eaff9e337..ab7704c3b 100644 --- a/manifest-delivery-worker-database.yml +++ b/manifest-delivery-worker-database.yml @@ -14,6 +14,6 @@ applications: - hosted-graphite instances: 2 memory: 256M - command: celery -A aws_run_celery.notify_celery worker --loglevel=INFO --concurrency=11 -Q db-sms,db-email + command: celery -A aws_run_celery.notify_celery worker --loglevel=INFO --concurrency=11 -Q db-sms,db-email,db-letter env: NOTIFY_APP_NAME: delivery-worker-database diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index cc1f8df61..9af7b3ff7 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -794,10 +794,6 @@ def test_should_use_email_template_and_persist_without_personalisation(sample_em queue='send-email') -class MyException(Exception): - pass - - def test_send_sms_should_go_to_retry_queue_if_database_errors(sample_template, mocker): notification = _notification_json(sample_template, "+447234123123") @@ -933,5 +929,4 @@ def test_persist_letter_saves_letter_to_database(sample_letter_job, mocker): (LETTER_TYPE, WithSubjectTemplate), ]) def test_get_template_class(template_type, expected_class): - template = Mock(template_type=template_type) - assert get_template_class(template) == expected_class + assert get_template_class(template_type) == expected_class