Implemented CheckIfPhoneNumberIsOptedOut + Tests + Error code

This commit is contained in:
Terry Cain 2017-09-19 23:54:13 +01:00
commit ba8a2ccfc5
No known key found for this signature in database
GPG key ID: 14D90844E4E9B9F3
2 changed files with 67 additions and 3 deletions

View file

@ -3,6 +3,8 @@ import boto3
import sure # noqa
from moto import mock_sns
from botocore.exceptions import ClientError
from nose.tools import assert_raises
@mock_sns
@ -30,3 +32,30 @@ def test_get_sms_attributes_filtered():
response['attributes'].should.contain('DefaultSMSType')
response['attributes'].should_not.contain('test')
response['attributes']['DefaultSMSType'].should.equal('Transactional')
@mock_sns
def test_check_not_opted_out():
conn = boto3.client('sns', region_name='us-east-1')
response = conn.check_if_phone_number_is_opted_out(phoneNumber='+447428545375')
response.should.contain('isOptedOut')
response['isOptedOut'].should.be(False)
@mock_sns
def test_check_opted_out(): # Ends in 99 so is opted out
conn = boto3.client('sns', region_name='us-east-1')
response = conn.check_if_phone_number_is_opted_out(phoneNumber='+447428545399')
response.should.contain('isOptedOut')
response['isOptedOut'].should.be(True)
@mock_sns
def test_check_opted_out_invalid():
conn = boto3.client('sns', region_name='us-east-1')
# Invalid phone number
with assert_raises(ClientError):
conn.check_if_phone_number_is_opted_out(phoneNumber='+44742LALALA')