How to use check_if_phone_number_is_opted_out method in localstack

Best Python code snippet using localstack_python

sns.py

Source:sns.py Github

copy

Full Screen

...12def add_permission(client=None, **kwargs):13 return client.add_permission(**kwargs)14@sts_conn('sns')15@rate_limited()16def check_if_phone_number_is_opted_out(client=None, **kwargs):17 return client.check_if_phone_number_is_opted_out(**kwargs)['isOptedOut']18@sts_conn('sns')19@rate_limited()20def confirm_subscription(client=None, **kwargs):21 return client.confirm_subscription(**kwargs)['SubscriptionArn']22@sts_conn('sns')23@rate_limited()24def create_platform_application(client=None, **kwargs):25 return client.create_platform_application(**kwargs)['PlatformApplicationArn']26@sts_conn('sns')27@rate_limited()28def create_platform_endpoint(client=None, **kwargs):29 return client.create_platform_endpoint(**kwargs)['EndpointArn']30@sts_conn('sns')31@rate_limited()...

Full Screen

Full Screen

test_sns.py

Source:test_sns.py Github

copy

Full Screen

1from unittest import mock2from unittest.mock import MagicMock3import boto34import pytest5import massgov.pfml.util.aws.sns as sns_util6@pytest.fixture7def mock_sns():8 mock_sns = MagicMock()9 mock_sns.check_if_phone_number_is_opted_out = MagicMock()10 mock_sns.opt_in_phone_number = MagicMock()11 return mock_sns12class TestPhoneNumberOptOut:13 @mock.patch("massgov.pfml.util.aws.sns.create_sns_client")14 def test_success(self, mock_create_sns, mock_sns):15 mock_create_sns.return_value = mock_sns16 sns_util.check_phone_number_opt_out("+15109283075")17 mock_sns.check_if_phone_number_is_opted_out.assert_called_with(phoneNumber="+15109283075")18 @mock.patch("massgov.pfml.util.aws.sns.create_sns_client")19 def test_invalid_parameter_raises_exception(self, mock_create_sns, mock_sns, caplog):20 mock_create_sns.return_value = mock_sns21 invalid_param = boto3.client("sns", "us-east-1").exceptions.InvalidParameterException(22 error_response={"Error": {"Code": "InvalidParameter"}}, operation_name=""23 )24 mock_check_phone = mock_sns.check_if_phone_number_is_opted_out25 mock_check_phone.side_effect = invalid_param26 with pytest.raises(Exception):27 sns_util.check_phone_number_opt_out("")28 assert "Invalid parameter in request" in caplog.text29class TestOptInPhoneNumber:30 @mock.patch("massgov.pfml.util.aws.sns.create_sns_client")31 def test_success(self, mock_create_sns, mock_sns):32 mock_create_sns.return_value = mock_sns33 sns_util.opt_in_phone_number("+15109283075")34 mock_sns.opt_in_phone_number.assert_called_with(phoneNumber="+15109283075")35 @mock.patch("massgov.pfml.util.aws.sns.create_sns_client")36 def test_invalid_parameter_raises_exception(self, mock_create_sns, mock_sns, caplog):37 mock_create_sns.return_value = mock_sns38 invalid_param = boto3.client("sns", "us-east-1").exceptions.InvalidParameterException(39 error_response={"Error": {"Code": "InvalidParameter"}}, operation_name=""40 )41 mock_opt_in = mock_sns.opt_in_phone_number42 mock_opt_in.side_effect = invalid_param43 with pytest.raises(Exception):44 sns_util.opt_in_phone_number("")45 assert "Invalid parameter in request" in caplog.text46 @mock.patch("massgov.pfml.util.aws.sns.create_sns_client")47 def test_throttled_exception_raises_exception(self, mock_create_sns, mock_sns, caplog):48 mock_create_sns.return_value = mock_sns49 throttled = boto3.client("sns", "us-east-1").exceptions.ThrottledException(50 error_response={"Error": {"Code": "Throttled"}}, operation_name=""51 )52 mock_opt_in = mock_sns.opt_in_phone_number53 mock_opt_in.side_effect = throttled54 with pytest.raises(Exception):55 sns_util.opt_in_phone_number("")...

Full Screen

Full Screen

PhoneVerifier.py

Source:PhoneVerifier.py Github

copy

Full Screen

...34 def send_sms_to_number(self, sms_number):35 # Use Amazon SNS to send rates information to a SMS number.36 # client = boto3.client('sns')37 # Verify that the SMS number has not opted out of SMS messages.38 response = client.check_if_phone_number_is_opted_out(sms_number)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful