Best Python code snippet using localstack_python
test_sns.py
Source:test_sns.py  
...545        self.assertEqual(e.response['Error']['Message'], 'Topic already exists with different tags')546        self.assertEqual(e.response['ResponseMetadata']['HTTPStatusCode'], 400)547        # clean up548        self.sns_client.delete_topic(TopicArn=topic_arn)549    def test_publish_by_path_parameters(self):550        topic_name = 'topic-{}'.format(short_uid())551        queue_name = 'queue-{}'.format(short_uid())552        message = 'test message {}'.format(short_uid())553        topic_arn = self.sns_client.create_topic(Name=topic_name)['TopicArn']554        base_url = '{}://{}:{}'.format(get_service_protocol(), config.LOCALSTACK_HOSTNAME, config.PORT_SNS)555        path = 'Action=Publish&Version=2010-03-31&TopicArn={}&Message={}'.format(topic_arn, message)556        queue_url = self.sqs_client.create_queue(QueueName=queue_name)['QueueUrl']557        queue_arn = aws_stack.sqs_queue_arn(queue_name)558        self.sns_client.subscribe(TopicArn=topic_arn, Protocol='sqs', Endpoint=queue_arn)559        r = requests.post(560            url='{}/?{}'.format(base_url, path),561            headers=aws_stack.mock_aws_request_headers('sns')562        )563        self.assertEqual(r.status_code, 200)...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!!
