Best Python code snippet using localstack_python
test_boto_sns.py
Source:test_boto_sns.py
...48 ret = self.run_function("boto_sns.create", [self.topic_name])49 self.assertSaltModuleTrueReturn(ret)50 ret = self.run_function("boto_sns.get_all_topics")51 self.assertIn(self.topic_name, list(ret.keys()))52 self.assertIn(self._get_arn(self.topic_name), list(ret.values()))53 def test_delete_non_existing(self):54 ret = self.run_function("boto_sns.delete", [self.topic_name])55 self.assertSaltModuleTrueReturn(ret)56 def test_delete_existing(self):57 self.run_function("boto_sns.create", [self.topic_name])58 ret = self.run_function("boto_sns.delete", [self.topic_name])59 self.assertSaltModuleTrueReturn(ret)60 ret = self.run_function("boto_sns.get_all_topics")61 self.assertNotIn(self.topic_name, list(ret.keys()))62 self.assertNotIn(self._get_arn(self.topic_name), list(ret.values()))63 def test_get_all_topics(self):64 self.topic_names.append(self.topic_name + "-2")65 for topic in self.topic_names:66 self.run_function("boto_sns.create", [topic])67 ret = self.run_function("boto_sns.get_all_topics")68 for topic in self.topic_names:69 self.assertIn(topic, list(ret.keys()))70 self.assertIn(self._get_arn(topic), list(ret.values()))71 def test_subscribe_and_get_all_subscriptions_by_topic(self):72 topic_name = self.topic_name73 ret = self.run_function("boto_sns.create", [topic_name])74 ret = self.run_function(75 "boto_sns.subscribe",76 [topic_name, "https", "https://www.example.com/sns/endpoint"],77 )78 self.assertSaltModuleTrueReturn(ret)79 ret = self.run_function("boto_sns.get_all_subscriptions_by_topic", [topic_name])80 self.assertDictContainsSubset(81 {"Protocol": "https", "Endpoint": "https://www.example.com/sns/endpoint"},82 ret[0],83 )84 def _get_arn(self, name):85 return "arn:aws:sns:us-east-1:{0}:{1}".format(self.account_id, name)86 @property87 def account_id(self):88 if not hasattr(self, "_account_id"):89 account_id = self.run_function("boto_iam.get_account_id")90 setattr(self, "_account_id", account_id)91 return self._account_id92 def assertSaltModuleTrueReturn(self, ret):93 self.assertIsInstance(ret, bool)94 self.assertTrue(ret)95 def assertSaltModuleFalseReturn(self, ret):96 self.assertIsInstance(ret, bool)...
boto_sns.py
Source:boto_sns.py
...40 self.run_function('boto_sns.create', ['my-test-topic'])41 self.run_function('boto_sns.create', ['my-second-test-topic'])42 ret = self.run_function('boto_sns.get_all_topics')43 self.assertIn('my-test-topic', ret.keys())44 self.assertIn(self._get_arn('my-test-topic'), ret.values())45 self.assertIn('my-second-test-topic', ret.keys())46 self.assertIn(self._get_arn('my-second-test-topic'), ret.values())47 def _get_arn(self, name):48 return 'arn:aws:sns:us-east-1:{0}:{1}'.format(self.account_id, name)49 @property50 def account_id(self):51 if not hasattr(self, '_account_id'):52 account_id = self.run_function('boto_iam.get_account_id')53 setattr(self, '_account_id', account_id)...
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!!