예제 #1
0
 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')
예제 #2
0
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
예제 #3
0
 def test_expect_delete_action_to_be_required(self):
     self.options.update({'delete_action': ''})
     CustomResource('bad_delete', 'file', self.options)
예제 #4
0
 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')
예제 #5
0
 def test_expect_region_to_be_required(self):
     self.options['queue_url'] = "http://noregion"
     CustomResource('name', 'title', self.options)
예제 #6
0
 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')
예제 #7
0
 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')
예제 #8
0
 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')
예제 #9
0
 def test_expect_region_to_be_parsed(self):
     resource = CustomResource('name', 'title', self.options)
     self.assertEqual(resource.region, 'us-east-1')
예제 #10
0
 def test_expect_source_file_to_be_set(self):
     resource = CustomResource('name', 'file', self.options)
     self.assertEqual(resource.source_file, 'file')
예제 #11
0
 def test_expect_queue_to_be_required(self):
     del self.options['queue_url']
     CustomResource('name', 'file', self.options)
예제 #12
0
 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')