def test_description_and_resources(): class R(Resource): __module__ = '' r = R() s = Stack(r, Description='My stack') assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Description': 'My stack', 'Resources': { 'R': { 'Type': 'R' } } })
def test_outputs(): r = ResourceWithAttributes() s = Stack(r) s.Outputs['output'] = r.attr1 assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Resources': { 'ResourceWithAttributes': { 'Type': 'ResourceWithAttributes' } }, 'Outputs': { 'output': {'Fn::GetAtt': ['ResourceWithAttributes', 'attr1']} } })
def test_parameters(): r = ResourceWithAttributes() s = Stack(r, p=Parameter()) assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Parameters': { 'p': { 'Type': 'String' } }, 'Resources': { 'ResourceWithAttributes': { 'Type': 'ResourceWithAttributes' } }, })
def test_parameters2(): from cfn.util import Parameter r = ResourceWithAttributes() p = Parameter('param1') s = Stack(r, p) assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Parameters': { 'param1': { 'Type': 'String' } }, 'Resources': { 'ResourceWithAttributes': { 'Type': 'ResourceWithAttributes' } }, })
def test_parameters_referencing(): r = ResourceWithProperties() p = Parameter() r.prop1 = p s = Stack(**locals()) assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Parameters': { 'p': { 'Type': 'String' } }, 'Resources': { 'r': { 'Type': 'ResourceWithProperties', 'Properties': { 'prop1': {'Ref': 'p'} } } }, })
def test_parameters_referencing_in_strings(): r = ResourceWithProperties() p = Parameter('param') r.prop1 = 'prefix{0}'.format(p) s = Stack(**locals()) assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Parameters': { 'param': { 'Type': 'String' } }, 'Resources': { 'r': { 'Type': 'ResourceWithProperties', 'Properties': { 'prop1': {'Fn::Join': ['', ['prefix', {'Ref': 'param'}]]} } } }, })
def test_description_in_json(): s = Stack(Description='My stack') assert_json(s, { 'AWSTemplateFormatVersion': '2010-09-09', 'Description': 'My stack' })