Added in publish by phone number
This commit is contained in:
parent
aad408b8ac
commit
56c65bc67c
5 changed files with 121 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ from freezegun import freeze_time
|
|||
import sure # noqa
|
||||
|
||||
from moto.packages.responses import responses
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_sns, mock_sqs
|
||||
from freezegun import freeze_time
|
||||
|
||||
|
|
@ -43,6 +44,49 @@ def test_publish_to_sqs():
|
|||
acquired_message.should.equal(expected)
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_publish_sms():
|
||||
client = boto3.client('sns', region_name='us-east-1')
|
||||
client.create_topic(Name="some-topic")
|
||||
resp = client.create_topic(Name="some-topic")
|
||||
arn = resp['TopicArn']
|
||||
|
||||
client.subscribe(
|
||||
TopicArn=arn,
|
||||
Protocol='sms',
|
||||
Endpoint='+15551234567'
|
||||
)
|
||||
|
||||
result = client.publish(PhoneNumber="+15551234567", Message="my message")
|
||||
result.should.contain('MessageId')
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_publish_bad_sms():
|
||||
client = boto3.client('sns', region_name='us-east-1')
|
||||
client.create_topic(Name="some-topic")
|
||||
resp = client.create_topic(Name="some-topic")
|
||||
arn = resp['TopicArn']
|
||||
|
||||
client.subscribe(
|
||||
TopicArn=arn,
|
||||
Protocol='sms',
|
||||
Endpoint='+15551234567'
|
||||
)
|
||||
|
||||
try:
|
||||
# Test invalid number
|
||||
client.publish(PhoneNumber="NAA+15551234567", Message="my message")
|
||||
except ClientError as err:
|
||||
err.response['Error']['Code'].should.equal('InvalidParameter')
|
||||
|
||||
try:
|
||||
# Test not found number
|
||||
client.publish(PhoneNumber="+44001234567", Message="my message")
|
||||
except ClientError as err:
|
||||
err.response['Error']['Code'].should.equal('ParameterValueInvalid')
|
||||
|
||||
|
||||
@mock_sqs
|
||||
@mock_sns
|
||||
def test_publish_to_sqs_dump_json():
|
||||
|
|
|
|||
|
|
@ -11,6 +11,39 @@ from moto import mock_sns
|
|||
from moto.sns.models import DEFAULT_PAGE_SIZE
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_subscribe_sms():
|
||||
client = boto3.client('sns', region_name='us-east-1')
|
||||
client.create_topic(Name="some-topic")
|
||||
resp = client.create_topic(Name="some-topic")
|
||||
arn = resp['TopicArn']
|
||||
|
||||
resp = client.subscribe(
|
||||
TopicArn=arn,
|
||||
Protocol='sms',
|
||||
Endpoint='+15551234567'
|
||||
)
|
||||
resp.should.contain('SubscriptionArn')
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_subscribe_bad_sms():
|
||||
client = boto3.client('sns', region_name='us-east-1')
|
||||
client.create_topic(Name="some-topic")
|
||||
resp = client.create_topic(Name="some-topic")
|
||||
arn = resp['TopicArn']
|
||||
|
||||
try:
|
||||
# Test invalid number
|
||||
client.subscribe(
|
||||
TopicArn=arn,
|
||||
Protocol='sms',
|
||||
Endpoint='NAA+15551234567'
|
||||
)
|
||||
except ClientError as err:
|
||||
err.response['Error']['Code'].should.equal('InvalidParameter')
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_creating_subscription():
|
||||
conn = boto3.client('sns', region_name='us-east-1')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue