From dba4e2ad890ad25864882722639d9fae1ab0a594 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 1 Jun 2017 17:27:09 +0100 Subject: [PATCH] mmg spell received incorrectly, lets use that --- app/notifications/receive_notifications.py | 8 ++++---- tests/app/notifications/test_receive_notification.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/notifications/receive_notifications.py b/app/notifications/receive_notifications.py index 1abc1c0f5..ad2dcf9d0 100644 --- a/app/notifications/receive_notifications.py +++ b/app/notifications/receive_notifications.py @@ -41,7 +41,7 @@ def receive_mmg_sms(): service = potential_services[0] - inbound = create_inbound_sms_object(service, post_data) + inbound = create_inbound_mmg_sms_object(service, post_data) current_app.logger.info('{} received inbound SMS with reference {}'.format(service.id, inbound.provider_reference)) @@ -52,15 +52,15 @@ def format_message(message): return unquote(message.replace('+', ' ')) -def create_inbound_sms_object(service, json): +def create_inbound_mmg_sms_object(service, json): message = format_message(json['Message']) user_number = normalise_phone_number(json['MSISDN']) inbound = InboundSms( service=service, notify_number=service.sms_sender, user_number=user_number, - provider_date=json['DateReceived'], - provider_reference=json['ID'], + provider_date=json.get('DateRecieved'), + provider_reference=json.get('ID'), content=message, ) dao_create_inbound_sms(inbound) diff --git a/tests/app/notifications/test_receive_notification.py b/tests/app/notifications/test_receive_notification.py index cd80e0481..5c583a17f 100644 --- a/tests/app/notifications/test_receive_notification.py +++ b/tests/app/notifications/test_receive_notification.py @@ -5,7 +5,7 @@ from flask import json from app.notifications.receive_notifications import ( format_message, - create_inbound_sms_object + create_inbound_mmg_sms_object ) from app.models import InboundSms @@ -19,7 +19,7 @@ def test_receive_notification_returns_received_to_mmg(client, sample_service): "Trigger": "Trigger?", "Number": "testing", "Channel": "SMS", - "DateReceived": "2012-06-27 12:33:00" + "DateRecieved": "2012-06-27 12:33:00" } response = client.post(path='/notifications/sms/receive/mmg', data=json.dumps(data), @@ -40,17 +40,17 @@ def test_format_message(message, expected_output): assert format_message(message) == expected_output -def test_create_inbound_sms_object(sample_service): +def test_create_inbound_mmg_sms_object(sample_service): sample_service.sms_sender = 'foo' data = { 'Message': 'hello+there+%F0%9F%93%A9', 'Number': 'foo', 'MSISDN': '07700 900 001', - 'DateReceived': '2017-01-02 03:04:05', + 'DateRecieved': '2017-01-02 03:04:05', 'ID': 'bar', } - inbound_sms = create_inbound_sms_object(sample_service, data) + inbound_sms = create_inbound_mmg_sms_object(sample_service, data) assert inbound_sms.service_id == sample_service.id assert inbound_sms.notify_number == 'foo' @@ -70,7 +70,7 @@ def test_receive_notification_error_if_not_single_matching_service(client, notif 'Message': 'hello', 'Number': notify_number, 'MSISDN': '7700900001', - 'DateReceived': '2017-01-02 03:04:05', + 'DateRecieved': '2017-01-02 03:04:05', 'ID': 'bar', } response = client.post(path='/notifications/sms/receive/mmg',