Path: blob/develop/tests/functional/cloudformation/test_create_stack.py
1567 views
#!/usr/bin/env python1# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License.13from awscli.testutils import BaseAWSCommandParamsTest141516class TestCreateStack(BaseAWSCommandParamsTest):1718prefix = 'cloudformation create-stack'1920def test_basic_create_stack(self):21cmdline = self.prefix22cmdline += ' --stack-name test-stack --template-url http://foo'23result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo'}24self.assert_params_for_cmd(cmdline, result)2526def test_create_stack_string_params(self):27cmdline = self.prefix28cmdline += ' --stack-name test-stack --template-url http://foo'29cmdline += ' --parameters ParameterKey=foo,ParameterValue=bar'30cmdline += ' ParameterKey=foo2,ParameterValue=bar2'31result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',32'Parameters': [33{'ParameterKey': 'foo', 'ParameterValue': 'bar'},34{'ParameterKey': 'foo2', 'ParameterValue': 'bar2'},35]}36self.assert_params_for_cmd(cmdline, result)3738def test_create_stack_for_csv_params_escaping(self):39# If a template is specified as a comma delimited list,40# we need to be able to quote the value or escape the comma.41cmdline = self.prefix42cmdline += ' --stack-name test-stack --template-url http://foo'43cmdline += ' --parameters ParameterKey=foo,ParameterValue=one\,two'44result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',45'Parameters': [{'ParameterKey': 'foo',46'ParameterValue': 'one,two'}]}47self.assert_params_for_cmd(cmdline, result)4849def test_create_stack_for_csv_with_quoting(self):50cmdline = self.prefix51cmdline += ' --stack-name test-stack --template-url http://foo'52# Note how we're quoting the value of parameter_value.53cmdline += ' --parameters ParameterKey=foo,ParameterValue="one,two"'54result = {'StackName': 'test-stack', 'TemplateURL': 'http://foo',55'Parameters': [{'ParameterKey': 'foo',56'ParameterValue': 'one,two'}]}57self.assert_params_for_cmd(cmdline, result)5859def test_can_handle_empty_parameters(self):60cmdline = self.prefix61cmdline += ' --stack-name test --parameters --template-url http://foo'62result = {'StackName': 'test', 'TemplateURL': 'http://foo',63'Parameters': []}64self.assert_params_for_cmd(cmdline, result)656667