Best Python code snippet using localstack_python
sns.py
Source:sns.py
...106def remove_permission(client=None, **kwargs):107 return client.remove_permission(**kwargs)108@sts_conn('sns')109@rate_limited()110def set_endpoint_attributes(client=None, **kwargs):111 return client.set_endpoint_attributes(**kwargs)112@sts_conn('sns')113@rate_limited()114def set_platform_application_attributes(client=None, **kwargs):115 return client.set_platform_application_attributes(**kwargs)116@sts_conn('sns')117@rate_limited()118def set_sms_attributes(client=None, **kwargs):119 return client.set_sms_attributes(**kwargs)120@sts_conn('sns')121@rate_limited()122def set_subscription_attributes(client=None, **kwargs):123 return client.set_subscription_attributes(**kwargs)124@sts_conn('sns')125@rate_limited()...
test_connection.py
Source:test_connection.py
1import time2from boto3.sns.utils import subscribe_sqs_queue3from boto3.sqs.utils import convert_queue_url_to_arn4from boto3.utils import json5from tests.integration.base import ConnectionTestCase6from tests import unittest7class SNSConnectionTestCase(ConnectionTestCase, unittest.TestCase):8 service_name = 'sns'9 ops = [10 'add_permission',11 'confirm_subscription',12 'connect_to',13 'create_platform_application',14 'create_platform_endpoint',15 'create_topic',16 'delete_endpoint',17 'delete_platform_application',18 'delete_topic',19 'get_endpoint_attributes',20 'get_platform_application_attributes',21 'get_subscription_attributes',22 'get_topic_attributes',23 'list_endpoints_by_platform_application',24 'list_platform_applications',25 'list_subscriptions',26 'list_subscriptions_by_topic',27 'list_topics',28 'publish',29 'remove_permission',30 'set_endpoint_attributes',31 'set_platform_application_attributes',32 'set_subscription_attributes',33 'set_topic_attributes',34 'subscribe',35 'unsubscribe',36 ]37 def test_integration(self):38 name = 'boto3_lives'39 topic_arn = self.conn.create_topic(40 name=name41 )['TopicArn']42 self.addCleanup(self.conn.delete_topic, topic_arn=topic_arn)43 # FIXME: Needs 100% more waiters.44 time.sleep(5)45 arns = [info['TopicArn'] for info in self.conn.list_topics()['Topics']]46 self.assertTrue(topic_arn in arns)47 # Subscribe first, so we get the notification.48 # To get the notification, we'll create an SQS queue it can deliver to.49 sqs = self.session.connect_to('sqs')50 url = sqs.create_queue(queue_name='boto3_sns_test')['QueueUrl']51 self.addCleanup(sqs.delete_queue, queue_url=url)52 queue_arn = convert_queue_url_to_arn(sqs, url)53 # Run the convenience method to do all the kinda-painful SNS/SQS setup.54 subscribe_sqs_queue(55 self.conn,56 sqs,57 topic_arn,58 url,59 queue_arn60 )61 # Now publish a test message.62 self.conn.publish(63 topic_arn=topic_arn,64 message=json.dumps({65 'default': 'This is a test.'66 })67 )68 time.sleep(5)69 # Ensure the publish succeeded.70 messages = sqs.receive_message(71 queue_url=url72 )73 self.assertTrue(len(messages['Messages']) > 0)74 raw_body = messages['Messages'][0]['Body']75 body = json.loads(raw_body)76 msg = json.loads(body.get('Message', '{}'))...
sns_interface.py
Source:sns_interface.py
...21 aws_access_key_id=aws_access_key_id,22 aws_secret_access_key=aws_secret_access_key23 )24 # TODO: This is untested25 return sns_client.set_endpoint_attributes(26 EndpointArn=endpoint_arn,27 Attributes={"Token": new_token}28 )29def push_message(endpoint_arn, message):30 # Get connection31 sns_client = boto3.client(32 'sns',33 region_name=region_name,34 aws_access_key_id=aws_access_key_id,35 aws_secret_access_key=aws_secret_access_key36 )37 return sns_client.publish(38 TargetArn=endpoint_arn,39 MessageStructure='string',...
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!!