Make sms code task use a reference too

- makes the fire text callback behave in consistent way
This commit is contained in:
Martyn Inglis
2016-03-10 15:51:11 +00:00
parent 1f22f2b7cc
commit 2922712f0b
5 changed files with 42 additions and 27 deletions

View File

@@ -619,7 +619,7 @@ def test_should_send_sms_code(mocker):
mocker.patch('app.firetext_client.send_sms')
send_sms_code(encrypted_notification)
firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code'])
firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code'], 'send-sms-code')
def test_should_throw_firetext_client_exception(mocker):
@@ -629,7 +629,7 @@ def test_should_throw_firetext_client_exception(mocker):
encrypted_notification = encryption.encrypt(notification)
mocker.patch('app.firetext_client.send_sms', side_effect=FiretextClientException(firetext_error()))
send_sms_code(encrypted_notification)
firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code'])
firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code'], 'send-sms-code')
def test_should_send_email_code(mocker):

View File

@@ -866,13 +866,13 @@ def test_firetext_callback_should_not_need_auth(notify_api):
with notify_api.test_client() as client:
response = client.post(
path='/notifications/sms/firetext',
data='mobile=441234123123&status=0&reference=&time=2016-03-10 14:17:00',
data='mobile=441234123123&status=0&reference=send-sms-code&time=2016-03-10 14:17:00',
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
assert response.status_code == 200
def test_firetext_callback_should_return_200_if_empty_reference(notify_api):
def test_firetext_callback_should_return_400_if_empty_reference(notify_api):
with notify_api.test_request_context():
with notify_api.test_client() as client:
response = client.post(
@@ -881,12 +881,12 @@ def test_firetext_callback_should_return_200_if_empty_reference(notify_api):
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
json_resp = json.loads(response.get_data(as_text=True))
assert response.status_code == 200
assert json_resp['result'] == 'success'
assert json_resp['message'] == 'Firetext callback succeeded'
assert response.status_code == 400
assert json_resp['result'] == 'error'
assert json_resp['message'] == 'Firetext callback failed: reference missing'
def test_firetext_callback_should_return_200_if_no_reference(notify_api):
def test_firetext_callback_should_return_400_if_no_reference(notify_api):
with notify_api.test_request_context():
with notify_api.test_client() as client:
response = client.post(
@@ -894,10 +894,24 @@ def test_firetext_callback_should_return_200_if_no_reference(notify_api):
data='mobile=441234123123&status=0&time=2016-03-10 14:17:00',
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
json_resp = json.loads(response.get_data(as_text=True))
assert response.status_code == 400
assert json_resp['result'] == 'error'
assert json_resp['message'] == 'Firetext callback failed: reference missing'
def test_firetext_callback_should_return_200_if_send_sms_reference(notify_api):
with notify_api.test_request_context():
with notify_api.test_client() as client:
response = client.post(
path='/notifications/sms/firetext',
data='mobile=441234123123&status=0&time=2016-03-10 14:17:00&reference=send-sms-code',
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
json_resp = json.loads(response.get_data(as_text=True))
assert response.status_code == 200
assert json_resp['result'] == 'success'
assert json_resp['message'] == 'Firetext callback succeeded'
assert json_resp['message'] == 'Firetext callback succeeded: send-sms-code'
def test_firetext_callback_should_return_400_if_no_status(notify_api):