mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-10 18:23:01 -04:00
fix tests
This commit is contained in:
@@ -2,37 +2,39 @@ import pytest
|
|||||||
|
|
||||||
from app import get_aws_sns_client
|
from app import get_aws_sns_client
|
||||||
|
|
||||||
aws_sns_client = get_aws_sns_client()
|
|
||||||
|
|
||||||
|
|
||||||
def test_send_sms_successful_returns_aws_sns_response(notify_api, mocker):
|
def test_send_sms_successful_returns_aws_sns_response(notify_api, mocker):
|
||||||
boto_mock = mocker.patch.object(aws_sns_client, "_client", create=True)
|
|
||||||
to = "16135555555"
|
to = "16135555555"
|
||||||
content = reference = "foo"
|
content = reference = "foo"
|
||||||
with notify_api.app_context():
|
with notify_api.app_context():
|
||||||
|
aws_sns_client = get_aws_sns_client()
|
||||||
|
boto_mock = mocker.patch.object(aws_sns_client, "_client", create=True)
|
||||||
aws_sns_client.send_sms(to, content, reference)
|
aws_sns_client.send_sms(to, content, reference)
|
||||||
boto_mock.publish.assert_called_once_with(
|
boto_mock.publish.assert_called_once_with(
|
||||||
PhoneNumber="+16135555555",
|
PhoneNumber="+16135555555",
|
||||||
Message=content,
|
Message=content,
|
||||||
MessageAttributes={
|
MessageAttributes={
|
||||||
"AWS.SNS.SMS.SMSType": {
|
"AWS.SNS.SMS.SMSType": {
|
||||||
"DataType": "String",
|
"DataType": "String",
|
||||||
"StringValue": "Transactional",
|
"StringValue": "Transactional",
|
||||||
|
},
|
||||||
|
"AWS.MM.SMS.OriginationNumber": {
|
||||||
|
"DataType": "String",
|
||||||
|
"StringValue": "+18556438890",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"AWS.MM.SMS.OriginationNumber": {
|
)
|
||||||
"DataType": "String",
|
|
||||||
"StringValue": "+18556438890",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_send_sms_returns_raises_error_if_there_is_no_valid_number_is_found(
|
def test_send_sms_returns_raises_error_if_there_is_no_valid_number_is_found(
|
||||||
notify_api, mocker
|
notify_api, mocker
|
||||||
):
|
):
|
||||||
mocker.patch.object(aws_sns_client, "_client", create=True)
|
with notify_api.app_context():
|
||||||
to = ""
|
aws_sns_client = get_aws_sns_client()
|
||||||
content = reference = "foo"
|
mocker.patch.object(aws_sns_client, "_client", create=True)
|
||||||
with pytest.raises(ValueError) as excinfo:
|
to = ""
|
||||||
aws_sns_client.send_sms(to, content, reference)
|
content = reference = "foo"
|
||||||
assert "No valid numbers found for SMS delivery" in str(excinfo.value)
|
with pytest.raises(ValueError) as excinfo:
|
||||||
|
aws_sns_client.send_sms(to, content, reference)
|
||||||
|
assert "No valid numbers found for SMS delivery" in str(excinfo.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user