diff --git a/app/__init__.py b/app/__init__.py index 2f834193b..d40b58895 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -123,6 +123,7 @@ def init_app(app): url_for('notifications.process_ses_response'), url_for('notifications.process_firetext_response'), url_for('notifications.process_mmg_response'), + url_for('notifications.receive_mmg_sms'), url_for('status.show_delivery_status'), url_for('spec.get_spec') ] diff --git a/app/notifications/rest.py b/app/notifications/rest.py index 4f3282cb9..a255f0850 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -49,6 +49,15 @@ from app.errors import ( register_errors(notifications) +@notifications.route('/notifications/sms/receive/mmg', methods=['POST']) +def receive_mmg_sms(): + post_data = request.get_json() + post_data.pop('MSISDN', None) + current_app.logger.info("Recieve notification form data: {}".format(post_data)) + + return "RECEIVED" + + @notifications.route('/notifications/email/ses', methods=['POST']) def process_ses_response(): client_name = 'SES' diff --git a/tests/app/notifications/test_receive_notification.py b/tests/app/notifications/test_receive_notification.py new file mode 100644 index 000000000..f325fe6f9 --- /dev/null +++ b/tests/app/notifications/test_receive_notification.py @@ -0,0 +1,18 @@ +from flask import json + + +def test_receive_notification_returns_received_to_mmg(client): + data = {"ID": "1234", + "MSISDN": "447700900855", + "Message": "Some message to notify", + "Trigger": "Trigger?", + "Number": "40604", + "Channel": "SMS", + "DateReceived": "2012-06-27-12:33:00" + } + response = client.post(path='/notifications/sms/receive/mmg', + data=json.dumps(data), + headers=[('Content-Type', 'application/json')]) + + assert response.status_code == 200 + assert response.get_data(as_text=True) == 'RECEIVED'