def test_expect_custom_action_to_override_default(self): self.options.update({ 'create_action': 'create', 'delete_action': 'delete', 'update_action': 'update' }) resource = CustomResource('name', 'file', self.options) self.assertEquals(resource._create_action, 'create') self.assertEquals(resource._update_action, 'update') self.assertEquals(resource._delete_action, 'delete')
def _parse_config(config_file): """Parses the provided configuration; returns list of sections When provided with a valid configuration file, will load all of the sections and return a list of CustomResources that match the provided configuration. It is assumed the file was already checked for existence before being passed in. """ config = ConfigParser.SafeConfigParser() config.read(config_file) resources = [] for resource_name in config.sections(): # Convert configuration options into dictionary (lowercasing all keys) options = dict((i[0].lower(), i[1]) for i in config.items(resource_name)) # Construct a new CustomResource with the provided configuration resources.append(CustomResource(resource_name, config_file, options)) return resources
def test_expect_delete_action_to_be_required(self): self.options.update({'delete_action': ''}) CustomResource('bad_delete', 'file', self.options)
def test_expect_default_action_to_be_used(self): resource = CustomResource('name', 'file', self.options) self.assertEqual(resource._create_action, 'action-default') self.assertEqual(resource._update_action, 'action-default') self.assertEqual(resource._delete_action, 'action-default')
def test_expect_region_to_be_required(self): self.options['queue_url'] = "http://noregion" CustomResource('name', 'title', self.options)
def test_expect_region_option_to_set(self): self.options['queue_url'] = "http://noregion" self.options['region'] = 'my-region' resource = CustomResource('name', 'title', self.options) self.assertEqual(resource.region, 'my-region')
def test_expect_region_option_to_override(self): self.options['region'] = 'fun-region' resource = CustomResource('name', 'title', self.options) self.assertEqual(resource.region, 'fun-region')
def test_expect_region_to_be_parsed_from_sqs_url(self): self.options['queue_url'] = "https://sqs.us-west-1.amazonaws.com" resource = CustomResource('name', 'title', self.options) self.assertEqual(resource.region, 'us-west-1')
def test_expect_region_to_be_parsed(self): resource = CustomResource('name', 'title', self.options) self.assertEqual(resource.region, 'us-east-1')
def test_expect_source_file_to_be_set(self): resource = CustomResource('name', 'file', self.options) self.assertEqual(resource.source_file, 'file')
def test_expect_queue_to_be_required(self): del self.options['queue_url'] CustomResource('name', 'file', self.options)
def test_expect_queue_to_be_set(self): resource = CustomResource('name', 'file', self.options) self.assertEqual(resource.queue_url, 'https://queue.us-east-1.amazonaws.com')