From 3ce6758f3eb0b705a0c22661cc19c8ef1e477e26 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 18 Feb 2016 09:59:18 +0000 Subject: [PATCH] Change names for clarity sake. Rename test. What we do when the validation_code fails to send is still to be decided. --- app/celery/tasks.py | 6 +++--- app/user/rest.py | 8 ++++---- tests/app/celery/test_tasks.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index d979f4aa7..e2403dec8 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -33,10 +33,10 @@ def send_sms(service_id, notification_id, encrypted_notification): @notify_celery.task(name='send-sms-code') -def send_sms_code(encrypted_notification): - notification = encryption.decrypt(encrypted_notification) +def send_sms_code(encrypted_verification): + verification_message = encryption.decrypt(encrypted_verification) try: - firetext_client.send_sms(notification['to'], notification['secret_code']) + firetext_client.send_sms(verification_message['to'], verification_message['secret_code']) except FiretextClientException as e: current_app.logger.debug(e) diff --git a/app/user/rest.py b/app/user/rest.py index cd493cccc..c08c02c0f 100644 --- a/app/user/rest.py +++ b/app/user/rest.py @@ -137,16 +137,16 @@ def send_user_code(user_id): create_user_code(user, secret_code, verify_code.get('code_type')) if verify_code.get('code_type') == 'sms': mobile = user.mobile_number if verify_code.get('to', None) is None else verify_code.get('to') - notification = {'to': mobile, 'secret_code': secret_code} - send_sms_code.apply_async([encryption.encrypt(notification)], queue='sms_code') + verification_message = {'to': mobile, 'secret_code': secret_code} + send_sms_code.apply_async([encryption.encrypt(verification_message)], queue='sms_code') elif verify_code.get('code_type') == 'email': email = user.email_address if verify_code.get('to', None) is None else verify_code.get('to') - notification = { + verification_message = { 'to_address': email, 'from_address': current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'], 'subject': 'Verification code', 'body': secret_code} - add_notification_to_queue(api_user['client'], 'admin', 'email', notification) + add_notification_to_queue(api_user['client'], 'admin', 'email', verification_message) else: abort(500) return jsonify({}), 204 diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index 93d7c4157..aa392dd33 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -90,7 +90,7 @@ def test_should_send_sms_code(mocker): firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code']) -def test_should_log_firetext_client_exception(mocker): +def test_should_throw_firetext_client_exception(mocker): notification = {'to': '+441234123123', 'secret_code': '12345'}