Use celery to send the email verification code.

This commit is contained in:
Rebecca Law
2016-02-18 09:52:27 +00:00
parent 9073814d9f
commit c1df61a7d4
6 changed files with 36 additions and 34 deletions

View File

@@ -301,7 +301,8 @@ def test_send_user_code_for_sms_with_optional_to_field(notify_api,
def test_send_user_code_for_email(notify_api,
sample_email_code,
mock_secret_code,
mock_celery_send_email_code):
mock_celery_send_email_code,
mock_encryption):
"""
Tests POST endpoint '/<user_id>/code' successful email
"""
@@ -317,18 +318,16 @@ def test_send_user_code_for_email(notify_api,
data=data,
headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 204
notification = {'to_address': sample_email_code.user.email_address,
'from_address': notify_api.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'],
'subject': 'Verification code',
'body': 11111}
encrypted = encryption.encrypt([notification])
app.celery.tasks.send_email_code.apply_async.assert_called_once_with([encrypted], queue='email_code')
app.celery.tasks.send_email_code.apply_async.assert_called_once_with(['something_encrypted'],
queue='email_code')
def test_send_user_code_for_email_uses_optional_to_field(notify_api,
sample_email_code,
mock_secret_code,
mock_celery_send_email_code):
mock_celery_send_email_code,
mock_encryption):
"""
Tests POST endpoint '/<user_id>/code' successful email with included in body
"""
@@ -344,13 +343,9 @@ def test_send_user_code_for_email_uses_optional_to_field(notify_api,
data=data,
headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 204
notification = json.dumps({'to_address': 'different@email.gov.uk',
'from_address': 'no-reply@notify.works',
'subject': 'Verification code',
'body': '11111'})
encrypted = encryption.encrypt([notification])
app.celery.tasks.send_email_code.apply_async.assert_called_once_with([encrypted], queue='email_code')
app.celery.tasks.send_email_code.apply_async.assert_called_once_with(['something_encrypted'],
queue='email_code')
def test_request_verify_code_schema_invalid_code_type(notify_api, notify_db, notify_db_session, sample_user):