From 5fc14940f3777af870ef9e2cae469b23ee521a71 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Mon, 13 Jun 2016 14:56:21 +0100 Subject: [PATCH] Let the send_email task set the from address --- app/celery/tasks.py | 8 +------- app/user/rest.py | 5 +---- tests/app/celery/test_tasks.py | 18 +++--------------- tests/app/user/test_rest_verify.py | 2 +- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index ceaf7c240..2859cf64c 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -180,16 +180,10 @@ def process_job(job_id): ) if template.template_type == 'email': - from_email = '"{}" <{}@{}>'.format( - service.name, - service.email_from, - current_app.config['NOTIFY_EMAIL_DOMAIN'] - ) - send_email.apply_async(( str(job.service_id), create_uuid(), - from_email.encode('ascii', 'ignore').decode('ascii'), + '', encrypted, datetime.utcnow().strftime(DATETIME_FORMAT)), {'reply_to_addresses': service.reply_to_email_address}, diff --git a/app/user/rest.py b/app/user/rest.py index bb31985eb..1907caff4 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -167,13 +167,10 @@ def send_user_email_verification(user_id): 'url': _create_verification_url(user_to_send_to, secret_code) } } - email_from = '"GOV.UK Notify" <{}>'.format( - current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'] - ) send_email.apply_async(( current_app.config['NOTIFY_SERVICE_ID'], str(uuid.uuid4()), - email_from, + '', encryption.encrypt(message), datetime.utcnow().strftime(DATETIME_FORMAT) ), queue='email-registration-verification') diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index 7034368d8..201982295 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -248,11 +248,7 @@ def test_should_process_email_job_if_exactly_on_send_limits(notify_db, ( str(job.service_id), "uuid", - "\"{}\" <{}@{}>".format( - service.name, - service.email_from, - "test.notify.com" - ), + "", "something_encrypted", "2016-01-01T11:09:00.061258" ), @@ -298,11 +294,7 @@ def test_should_process_email_job(sample_email_job, mocker, mock_celery_remove_j ( str(sample_email_job.service_id), "uuid", - "\"{}\" <{}@{}>".format( - sample_email_job.service.name, - sample_email_job.service.email_from, - "test.notify.com" - ), + "", "something_encrypted", "2016-01-01T11:09:00.061258" ), @@ -960,11 +952,7 @@ def test_process_email_job_should_use_reply_to_email_if_present(sample_email_job ( str(sample_email_job.service_id), "uuid", - "\"{}\" <{}@{}>".format( - sample_email_job.service.name, - sample_email_job.service.email_from, - "test.notify.com" - ), + "", "something_encrypted", ANY ), diff --git a/tests/app/user/test_rest_verify.py b/tests/app/user/test_rest_verify.py index 7f2a6130e..9d2d31687 100644 --- a/tests/app/user/test_rest_verify.py +++ b/tests/app/user/test_rest_verify.py @@ -331,7 +331,7 @@ def test_send_user_email_verification(notify_api, app.celery.tasks.send_email.apply_async.assert_called_once_with( (str(current_app.config['NOTIFY_SERVICE_ID']), 'some_uuid', - '"GOV.UK Notify" <{}>'.format(current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS']), + '', "something_encrypted", "2016-01-01T11:09:00.061258"), queue="email-registration-verification")