Stop sending the encrypted message to the send_sms_to_provider task.

Everything the task needs is now stored in the db.
This commit is contained in:
Rebecca Law
2016-06-23 09:41:21 +01:00
parent 02e37dee3a
commit 8f19ad19f8
3 changed files with 10 additions and 15 deletions

View File

@@ -161,7 +161,7 @@ def send_sms(self, service_id, notification_id, encrypted_notification, created_
) )
dao_create_notification(notification_db_object, TEMPLATE_TYPE_SMS) dao_create_notification(notification_db_object, TEMPLATE_TYPE_SMS)
send_sms_to_provider.apply_async((service_id, notification_id, encrypted_notification), queue='sms') send_sms_to_provider.apply_async((service_id, notification_id), queue='sms')
current_app.logger.info( current_app.logger.info(
"SMS {} created at {} sent at {}".format(notification_id, created_at, sent_at) "SMS {} created at {} sent at {}".format(notification_id, created_at, sent_at)

View File

@@ -1,20 +1,18 @@
from datetime import datetime
from celery.exceptions import MaxRetriesExceededError from celery.exceptions import MaxRetriesExceededError
from mock import ANY, call from mock import ANY, call
from notifications_utils.recipients import validate_phone_number, format_phone_number
from app import statsd_client, mmg_client, encryption from app import statsd_client, mmg_client
from app.celery import provider_tasks from app.celery import provider_tasks
from app.celery.provider_tasks import send_sms_to_provider from app.celery.provider_tasks import send_sms_to_provider
from app.celery.research_mode_tasks import send_sms_response
from app.celery.tasks import provider_to_use from app.celery.tasks import provider_to_use
from app.clients.sms import SmsClientException from app.clients.sms import SmsClientException
from app.dao import provider_statistics_dao
from datetime import datetime
from freezegun import freeze_time
from app.dao import notifications_dao, provider_details_dao from app.dao import notifications_dao, provider_details_dao
from notifications_utils.recipients import validate_phone_number, format_phone_number from app.dao import provider_statistics_dao
from app.celery.research_mode_tasks import send_sms_response
from app.models import Notification, NotificationStatistics, Job from app.models import Notification, NotificationStatistics, Job
from tests.app.conftest import ( from tests.app.conftest import (
sample_notification sample_notification
) )

View File

@@ -332,8 +332,7 @@ def test_should_send_template_to_correct_sms_task_and_persist(sample_template_wi
provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with( provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with(
(sample_template_with_placeholders.service_id, (sample_template_with_placeholders.service_id,
notification_id, notification_id),
encryption.encrypt(notification)),
queue="sms" queue="sms"
) )
@@ -371,8 +370,7 @@ def test_should_send_sms_if_restricted_service_and_valid_number(notify_db, notif
provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with( provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with(
(service.id, (service.id,
notification_id, notification_id),
encrypt_notification),
queue="sms" queue="sms"
) )
@@ -480,8 +478,7 @@ def test_should_send_sms_template_to_and_persist_with_job_id(sample_job, mocker)
) )
provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with( provider_tasks.send_sms_to_provider.apply_async.assert_called_once_with(
(sample_job.service.id, (sample_job.service.id,
notification_id, notification_id),
encryption.encrypt(notification)),
queue="sms" queue="sms"
) )
persisted_notification = Notification.query.filter_by(id=notification_id).one() persisted_notification = Notification.query.filter_by(id=notification_id).one()