From fc61fd2086a57e6363abad17202793c54ce90b41 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 8 May 2019 16:31:51 +0100 Subject: [PATCH] Remove updating provider on failure - we aren't sure yet who is sending the message the callback code sets that property as a fallback anyway. Remove debug statements. --- app/delivery/send_to_providers.py | 13 +------------ tests/app/delivery/test_send_to_providers.py | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index bcf699ff2..b4475623d 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -7,7 +7,6 @@ from notifications_utils.recipients import ( validate_and_format_email_address ) from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTemplate, SMSMessageTemplate -from requests.exceptions import HTTPError from app import clients, statsd_client, create_uuid from app.dao.notifications_dao import ( @@ -26,7 +25,6 @@ from app.models import ( BRANDING_BOTH, BRANDING_ORG_BANNER, EMAIL_TYPE, - NOTIFICATION_CREATED, NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_SENT, NOTIFICATION_SENDING @@ -42,9 +40,7 @@ def send_sms_to_provider(notification): if notification.status == 'created': provider = provider_to_use(SMS_TYPE, notification.id, notification.international) - current_app.logger.debug( - "Starting sending SMS {} to provider at {}".format(notification.id, datetime.utcnow()) - ) + template_model = dao_get_template_by_id(notification.template_id, notification.template_version) template = SMSMessageTemplate( @@ -68,7 +64,6 @@ def send_sms_to_provider(notification): ) except Exception as e: notification.billable_units = template.fragment_count - notification.sent_by = provider.get_name() dao_update_notification(notification) dao_toggle_sms_provider(provider.name) raise e @@ -76,9 +71,6 @@ def send_sms_to_provider(notification): notification.billable_units = template.fragment_count update_notification_to_sending(notification, provider) - current_app.logger.debug( - "SMS {} sent to provider {} at {}".format(notification.id, provider.get_name(), notification.sent_at) - ) delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000 statsd_client.timing("sms.total-time", delta_milliseconds) @@ -125,9 +117,6 @@ def send_email_to_provider(notification): notification.reference = reference update_notification_to_sending(notification, provider) - current_app.logger.debug( - "Email {} sent to provider at {}".format(notification.id, notification.sent_at) - ) delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000 statsd_client.timing("email.total-time", delta_milliseconds) diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index e3002a8c3..8d4334da9 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -539,7 +539,7 @@ def test_should_update_billable_units_according_to_research_mode_and_key_type( assert notification.billable_units == billable_units -def test_should_set_notification_billable_units_and_provider_if_sending_to_provider_fails( +def test_should_set_notification_billable_units_if_sending_to_provider_fails( sample_notification, mocker, ): @@ -553,7 +553,6 @@ def test_should_set_notification_billable_units_and_provider_if_sending_to_provi send_to_providers.send_sms_to_provider(sample_notification) assert sample_notification.billable_units == 1 - assert sample_notification.sent_by == 'mmg' assert mock_toggle_provider.called