Best Python code snippet using localstack_python
sns.py
Source:sns.py
...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()126def set_topic_attributes(client=None, **kwargs):127 return client.set_topic_attributes(**kwargs)128@sts_conn('sns')129@rate_limited()...
client.py
Source:client.py
...63 def remove_permission(self, TopicArn: str, Label: str):64 pass65 def set_endpoint_attributes(self, EndpointArn: str, Attributes: Dict):66 pass67 def set_platform_application_attributes(self, PlatformApplicationArn: str, Attributes: Dict):68 pass69 def set_sms_attributes(self, attributes: Dict) -> Dict:70 pass71 def set_subscription_attributes(self, SubscriptionArn: str, AttributeName: str, AttributeValue: str = None):72 pass73 def set_topic_attributes(self, TopicArn: str, AttributeName: str, AttributeValue: str = None):74 pass75 def subscribe(self, TopicArn: str, Protocol: str, Endpoint: str = None, Attributes: Dict = None, ReturnSubscriptionArn: bool = None) -> Dict:76 pass77 def tag_resource(self, ResourceArn: str, Tags: List) -> Dict:78 pass79 def unsubscribe(self, SubscriptionArn: str):80 pass81 def untag_resource(self, ResourceArn: str, TagKeys: List) -> Dict:...
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', '{}'))...
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!!