Add internation api key for firetext.

We want to start using Firetext for sending international SMS. They
require us to use a different API key for international SMS because it
requires a new code path to switch the sender ID to something that the
country will accept.
This PR does not include switching the sender of international SMS to
Firetext but sets us up to do so.
This commit is contained in:
Rebecca Law
2021-03-16 14:53:42 +00:00
parent f2167aae2b
commit f3fdd3b09b
9 changed files with 66 additions and 29 deletions

View File

@@ -44,7 +44,7 @@ def test_send_sms_successful_returns_mmg_response(notify_api, mocker):
with requests_mock.Mocker() as request_mock:
request_mock.post('https://example.com/mmg', json=response_dict, status_code=200)
response = mmg_client.send_sms(to, content, reference)
response = mmg_client.send_sms(to, content, reference, False)
response_json = response.json()
assert response.status_code == 200
@@ -59,7 +59,7 @@ def test_send_sms_calls_mmg_correctly(notify_api, mocker):
with requests_mock.Mocker() as request_mock:
request_mock.post('https://example.com/mmg', json=response_dict, status_code=200)
mmg_client.send_sms(to, content, reference)
mmg_client.send_sms(to, content, reference, False)
assert request_mock.call_count == 1
assert request_mock.request_history[0].url == 'https://example.com/mmg'
@@ -83,7 +83,7 @@ def test_send_sms_raises_if_mmg_rejects(notify_api, mocker):
with pytest.raises(SmsClientResponseException) as exc, requests_mock.Mocker() as request_mock:
request_mock.post('https://example.com/mmg', json=response_dict, status_code=400)
mmg_client.send_sms(to, content, reference)
mmg_client.send_sms(to, content, reference, False)
assert exc.value.status_code == 400
assert '"Error": 206' in exc.value.text
@@ -100,7 +100,7 @@ def test_send_sms_override_configured_shortcode_with_sender(notify_api, mocker):
with requests_mock.Mocker() as request_mock:
request_mock.post('https://example.com/mmg', json=response_dict, status_code=200)
mmg_client.send_sms(to, content, reference, sender=sender)
mmg_client.send_sms(to, content, reference, False, sender=sender)
request_args = request_mock.request_history[0].json()
assert request_args['sender'] == 'fromservice'
@@ -112,7 +112,7 @@ def test_send_sms_raises_if_mmg_fails_to_return_json(notify_api, mocker):
with pytest.raises(SmsClientResponseException) as exc, requests_mock.Mocker() as request_mock:
request_mock.post('https://example.com/mmg', text=response_dict, status_code=200)
mmg_client.send_sms(to, content, reference)
mmg_client.send_sms(to, content, reference, False)
assert 'Code 200 text NOT AT ALL VALID JSON {"key" : "value"}} exception Expecting value: line 1 column 1 (char 0)' in str(exc.value) # noqa
assert exc.value.status_code == 200
@@ -124,7 +124,7 @@ def test_send_sms_raises_if_mmg_rejects_with_connect_timeout(rmock):
with pytest.raises(MMGClientResponseException) as exc:
rmock.register_uri('POST', 'https://example.com/mmg', exc=ConnectTimeout)
mmg_client.send_sms(to, content, reference)
mmg_client.send_sms(to, content, reference, False)
assert exc.value.status_code == 504
assert exc.value.text == 'Gateway Time-out'
@@ -135,7 +135,7 @@ def test_send_sms_raises_if_mmg_rejects_with_read_timeout(rmock):
with pytest.raises(MMGClientResponseException) as exc:
rmock.register_uri('POST', 'https://example.com/mmg', exc=ReadTimeout)
mmg_client.send_sms(to, content, reference)
mmg_client.send_sms(to, content, reference, False)
assert exc.value.status_code == 504
assert exc.value.text == 'Gateway Time-out'