Best Python code snippet using localstack_python
config_recorder.py
Source:config_recorder.py
...27 i_am_plural = 'Config Recorders'28 def __init__(self, accounts=None, debug=False):29 super(ConfigRecorder, self).__init__(accounts=accounts, debug=debug)30 @record_exception(source="configrecorder")31 def describe_configuration_recorders(self, **kwargs):32 from security_monkey.common.sts_connect import connect33 config_service = connect(kwargs['account_name'], 'boto3.config.client',34 region=kwargs['region'])35 response = self.wrap_aws_rate_limited_call(config_service.describe_configuration_recorders)36 config_recorders = response.get('ConfigurationRecorders', [])37 return [recorder for recorder in config_recorders if not self.check_ignore_list(recorder.get('name'))]38 def slurp(self):39 """40 :returns: item_list - list of AWS Config recorders.41 :returns: exception_map - A dict where the keys are a tuple containing the42 location of the exception and the value is the actual exception43 """44 self.prep_for_slurp()45 @iter_account_region(index=self.index, accounts=self.accounts, service_name='config')46 def slurp_items(**kwargs):47 item_list = []48 exception_map = {}49 app.logger.debug("Checking {}/{}/{}".format(self.index,50 kwargs['account_name'],51 kwargs['region']))52 config_recorders = self.describe_configuration_recorders(**kwargs)53 if config_recorders:54 app.logger.debug("Found {} {}.".format(len(config_recorders), self.i_am_plural))55 for recorder in config_recorders:56 name = recorder.get('name')57 item_config = {58 'name': name,59 'role_arn': recorder.get('roleARN'),60 'recording_group': recorder.get('recordingGroup')61 }62 item = ConfigRecorderItem(region=kwargs['region'],63 account=kwargs['account_name'],64 name=name, config=item_config, source_watcher=self)65 item_list.append(item)66 return item_list, exception_map...
test_configservice.py
Source:test_configservice.py
...24from tests.compat import unittest25class TestConfigService(unittest.TestCase):26 def setUp(self):27 self.configservice = boto.connect_configservice()28 def test_describe_configuration_recorders(self):29 response = self.configservice.describe_configuration_recorders()30 self.assertIn('ConfigurationRecorders', response)31 def test_handle_no_such_configuration_recorder(self):32 with self.assertRaises(NoSuchConfigurationRecorderException):33 self.configservice.describe_configuration_recorders(34 configuration_recorder_names=['non-existant-recorder'])35 def test_connect_to_non_us_east_1(self):36 self.configservice = boto.configservice.connect_to_region('us-west-2')37 response = self.configservice.describe_configuration_recorders()...
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!!