Change CloudFormationResponse.get_template() to return GetTemplateResponse/GetTemplateResult/TemplateBody

This commit is contained in:
Hugo Lopes Tavares 2015-10-05 15:21:30 -04:00
parent f72613cc47
commit e5675e9533
2 changed files with 56 additions and 6 deletions

View File

@ -86,9 +86,19 @@ class CloudFormationResponse(BaseResponse):
def get_template(self):
name_or_stack_id = self.querystring.get('StackName')[0]
stack = self.cloudformation_backend.get_stack(name_or_stack_id)
return stack.template
response = {
"GetTemplateResponse": {
"GetTemplateResult": {
"TemplateBody": stack.template,
"ResponseMetadata": {
"RequestId": "2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE"
}
}
}
}
return json.dumps(response)
def update_stack(self):
stack_name = self._get_param('StackName')

View File

@ -40,7 +40,17 @@ def test_create_stack():
stack = conn.describe_stacks()[0]
stack.stack_name.should.equal('test_stack')
stack.get_template().should.equal(dummy_template)
stack.get_template().should.equal({
'GetTemplateResponse': {
'GetTemplateResult': {
'TemplateBody': dummy_template_json,
'ResponseMetadata': {
'RequestId': '2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE'
}
}
}
})
@mock_cloudformation
@ -83,7 +93,18 @@ def test_create_stack_from_s3_url():
stack = conn.describe_stacks()[0]
stack.stack_name.should.equal('new-stack')
stack.get_template().should.equal(dummy_template)
stack.get_template().should.equal(
{
'GetTemplateResponse': {
'GetTemplateResult': {
'TemplateBody': dummy_template_json,
'ResponseMetadata': {
'RequestId': '2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE'
}
}
}
})
@mock_cloudformation
@ -138,7 +159,17 @@ def test_get_template_by_name():
)
template = conn.get_template("test_stack")
template.should.equal(dummy_template)
template.should.equal({
'GetTemplateResponse': {
'GetTemplateResult': {
'TemplateBody': dummy_template_json,
'ResponseMetadata': {
'RequestId': '2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE'
}
}
}
})
@mock_cloudformation
@ -243,4 +274,13 @@ def test_stack_tags():
# conn.update_stack("test_stack", dummy_template_json2)
# stack = conn.describe_stacks()[0]
# stack.get_template().should.equal(dummy_template2)
# stack.get_template().should.equal({
# 'GetTemplateResponse': {
# 'GetTemplateResult': {
# 'TemplateBody': dummy_template_json2,
# 'ResponseMetadata': {
# 'RequestId': '2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE'
# }
# }
# }
# })