Best Python code snippet using localstack_python
test_sns.py
Source:test_sns.py
...318 tags = self.sns_client.list_tags_for_resource(ResourceArn=self.topic_arn)319 self.assertEqual(len(tags['Tags']), 1)320 self.assertEqual(tags['Tags'][0]['Key'], '456')321 self.assertEqual(tags['Tags'][0]['Value'], 'pqr')322 def test_topic_subscription(self):323 subscription = self.sns_client.subscribe(324 TopicArn=self.topic_arn,325 Protocol='email',326 Endpoint='localstack@yopmail.com'327 )328 def check_subscription():329 subscription_arn = subscription['SubscriptionArn']330 subscription_obj = sns_listener.SUBSCRIPTION_STATUS[subscription_arn]331 self.assertEqual(subscription_obj['Status'], 'Not Subscribed')332 _token = subscription_obj['Token']333 self.sns_client.confirm_subscription(334 TopicArn=self.topic_arn,335 Token=_token336 )...
test_demo_kafka.py
Source:test_demo_kafka.py
...4from kafka import KafkaConsumer5from kafka import KafkaProducer6from kafka.errors import KafkaError, KafkaTimeoutError7class TestKafkaDemoConsumer():8 def test_topic_subscription(self):9 """Test the Consumer ability to subscribe to the Topic."""10 consumer = KafkaConsumer('aiven-job-demo2')11 sub = consumer.subscription()12 assert sub is not consumer.subscription()13 assert sub == set(['aiven-job-demo2'])14 sub.add('other-topic')15 assert consumer.subscription() == set(['aiven-job-demo2'])16 assert len(consumer.topics()) > 117class TestKafkaDemoProducer():18 """Make sure Zookeper and Kafka servers are up before running these tests."""19 topic = 'aiven-job-demo2'20 def test_producer(self):21 """Test the Producer sending messages."""22 producer = KafkaProducer(...
test_consumer.py
Source:test_consumer.py
...5class TestConsumer(TestCase):6 def setUp(self):7 self.topics = ['ResponseEvent', 'ModelChange-Certificate']8 self.consumer = Consumer(*self.topics)9 def test_topic_subscription(self):10 inner_consumer = self.consumer.consumer11 self.assertIsNotNone(inner_consumer)12 self.assertIsInstance(inner_consumer, KafkaConsumer)13 def test_make_topic_regex(self):14 assert self.consumer._make_topic_regex() == r'(ResponseEvent)|(ModelChange-Certificate)'15 def test_complicated_topic_regex(self):16 consumer = Consumer('ModelChange-*', 'ResponseEvent')17 assert consumer._make_topic_regex() == r'(ModelChange-*)|(ResponseEvent)'18 def test_complicated_topic_regex_matches(self):19 consumer = Consumer('ModelChange-*')20 pattern = re.compile(consumer._make_topic_regex())21 assert pattern.match('ModelChange-Certificate') is not None22 assert pattern.match('ModelChange-OptionGrant') is not None23 def test_regex_matches_literals(self):...
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!!