The notification.to field is being formatted to be +447...

This meant that the research mode task would never work.
Also the way we mark data as "temporary-failure" with firetext is with first a pending status callback then a declined callback.
This PR changes the research mode task to account for that situation.
This commit is contained in:
Rebecca Law
2017-01-20 13:17:53 +00:00
parent 645a6fb3cf
commit 5e3bb08860
2 changed files with 37 additions and 21 deletions

View File

@@ -6,9 +6,9 @@ from requests import request, RequestException, HTTPError
from app.models import SMS_TYPE
temp_fail = "07700900003"
perm_fail = "07700900002"
delivered = "07700900001"
temp_fail = "7700900003"
perm_fail = "7700900002"
delivered = "7700900001"
delivered_email = "delivered@simulator.notify"
perm_fail_email = "perm-fail@simulator.notify"
@@ -23,6 +23,12 @@ def send_sms_response(provider, reference, to):
else:
headers = {"Content-type": "application/x-www-form-urlencoded"}
body = firetext_callback(reference, to)
# to simulate getting a temporary_failure from firetext
# we need to send a pending status updated then a permanent-failure
if body['status'] == '2': # pending status
make_request(SMS_TYPE, provider, body, headers)
body = firetext_callback(reference, perm_fail)
make_request(SMS_TYPE, provider, body, headers)
@@ -71,9 +77,9 @@ def mmg_callback(notification_id, to):
status: 5 - rejected (perm failure)
"""
if to == temp_fail:
if to.strip().endswith(temp_fail):
status = "4"
elif to == perm_fail:
elif to.strip().endswith(perm_fail):
status = "5"
else:
status = "3"
@@ -90,8 +96,10 @@ def firetext_callback(notification_id, to):
status: 0 - delivered
status: 1 - perm failure
"""
if to == perm_fail:
if to.strip().endswith(perm_fail):
status = "1"
elif to.strip().endswith(temp_fail):
status = "2"
else:
status = "0"
return {