mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Use celery to send the email verification code.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user