Best Python code snippet using localstack_python
sns.py
Source: sns.py
...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()...
test_sns.py
Source: test_sns.py
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("")...
PhoneVerifier.py
Source: PhoneVerifier.py
...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)...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!