Merge pull request #1008 from alphagov/recieved

mmg spell received incorrectly, lets use that
This commit is contained in:
Leo Hemsted
2017-06-02 09:09:55 +01:00
committed by GitHub
2 changed files with 10 additions and 10 deletions

View File

@@ -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)

View File

@@ -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',