def test_merging_occurs_after_transformation(self): enhancements = { 'transformations': { 'operation-name': { 'remove': r'\d{4}_\d{2}_\d{2}' } }, 'operations': { 'RealOperation': { 'input': { 'checksum': 'md5', } }, } } model = ModelFiles(SERVICES, regions={}, retry={}, enhancements=enhancements) model.enhancements = enhancements new_model = translate(model) self.assertIn('RealOperation', new_model['operations']) self.assertEqual( new_model['operations']['RealOperation']['input']['checksum'], 'md5')
def test_resolve_reference(self): model = ModelFiles(SERVICES, {}, self.retry, {}) new_model = translate(model) operation_config = new_model['retry']['AssumeRole'] # And we should resolve references. self.assertEqual(operation_config['policies']['other'], {"from": {"definition": "file"}})
def test_merging_occurs_after_transformation(self): enhancements = { 'transformations': { 'operation-name': {'remove': r'\d{4}_\d{2}_\d{2}'} }, 'operations': { 'RealOperation': { 'input': { 'checksum': 'md5', } }, } } model = ModelFiles(SERVICES, retry={}, enhancements=enhancements) model.enhancements = enhancements new_model = translate(model) self.assertIn('RealOperation', new_model['operations']) self.assertEqual( new_model['operations']['RealOperation']['input']['checksum'], 'md5')
def test_remove_deprecated_ops(self): enhancements = { 'transformations': { 'remove-deprecated-operations': {'deprecated_keyword': 'deprecated'} } } model = ModelFiles(SERVICES, retry={}, enhancements=enhancements) new_model = translate(model) # The deprecated operation should be gone self.assertNotIn('DeprecatedOperation2', new_model['operations'])
def test_remove_deprecated_params(self): enhancements = { 'transformations': { 'remove-deprecated-params': {'deprecated_keyword': 'deprecated'} } } model = ModelFiles(SERVICES, retry={}, enhancements=enhancements) new_model = translate(model) operation = new_model['operations']['DeprecatedOperation'] # The deprecated param should be gone, the other should remain self.assertIn('FooBar', operation['input']['members']) self.assertNotIn('FieBaz', operation['input']['members'])
def test_rename_param(self): enhancements = { 'transformations': { 'renames': { 'RenameOperation.input.members.RenameMe': 'BeenRenamed', } } } model = ModelFiles(SERVICES, retry={}, enhancements=enhancements) new_model = translate(model) arguments = new_model['operations']['RenameOperation']['input']['members'] self.assertNotIn('RenameMe', arguments) self.assertIn('BeenRenamed', arguments)
def test_replace_operation_key_name(self): enhancements = { 'transformations': { 'operation-name': {'remove': r'\d{4}_\d{2}_\d{2}'} } } model = ModelFiles(SERVICES, regions={}, retry={}, enhancements=enhancements) new_model = translate(model) # But the key into the operation dict is stripped of the # matched regex. self.assertEqual(list(sorted(new_model['operations'].keys())), ['AssumeRole', 'DeprecatedOperation', 'DeprecatedOperation2', 'NoOutputOperation', 'RealOperation', 'RenameOperation']) # But the name key attribute is left unchanged. self.assertEqual(new_model['operations']['RealOperation']['name'], 'RealOperation2013_02_04')
def test_remove_deprecated_params(self): enhancements = { "transformations": { "filter-documentation": { "filter": { "regex": "<!\\[CDATA\\[.*\\]\\]>", "replacement": "" } } } } model = ModelFiles(SERVICES, retry={}, enhancements=enhancements) new_model = translate(model) operation = new_model['operations']['DeprecatedOperation'] # The deprecated param should be gone, the other should remain self.assertEqual(operation['documentation'], 'This is my stuff') param = operation['input']['members']['FooBar'] self.assertEqual(param['documentation'], 'blah blah blah blah')
def test_inject_retry_config(self): model = ModelFiles(SERVICES, {}, self.retry, {}) new_model = translate(model) self.assertIn('retry', new_model) retry = new_model['retry'] self.assertIn('__default__', retry) self.assertEqual( retry['__default__'], { "max_attempts": 5, "delay": "service_specific_delay", "policies": { "global_one": "global", "override_me": "service", "service_one": "service", } }) # Policies should be merged. operation_config = retry['AssumeRole'] self.assertEqual(operation_config['policies']['name'], 'policy')
def setUp(self): self.model = ModelFiles(SERVICES, {}, {}, {})