def testOutputWithChildren(self): output = yaml.dump( { 'AWSTemplateFormatVersion': '2010-09-09', 'Description': 'The Description', 'Resources': { 'GeneratedClass0': { 'Type': 'AWS::SomeService::GeneratedClass', 'Properties': { 'Parameter1': 'az-1', 'Parameter2': 'ami-12345678' } }, 'GeneratedClass1': { 'Type': 'AWS::SomeService::GeneratedClass', 'Properties': { 'Parameter1': 'az-2', 'Parameter2': 'ami-23456789' } } } }, default_flow_style=False) subject = cfngenerator.CFTemplate("The Description") subject.add( cfngenerator.SomeService_GeneratedClass(Parameter1="az-1", Parameter2="ami-12345678")) subject.add( cfngenerator.SomeService_GeneratedClass(Parameter1="az-2", Parameter2="ami-23456789")) self.assertEqual(subject.output(), output)
def testGetResourcesForOutput(self): output = { 'GeneratedClass0': { 'Type': 'AWS::SomeService::GeneratedClass', 'Properties': { 'Parameter1': 'az-1', 'Parameter2': 'ami-12345678' } }, 'GeneratedClass1': { 'Type': 'AWS::SomeService::GeneratedClass', 'Properties': { 'Parameter1': 'az-2', 'Parameter2': 'ami-23456789' } } } subject = cfngenerator.CFTemplate("The Description") subject.add( cfngenerator.SomeService_GeneratedClass(Parameter1="az-1", Parameter2="ami-12345678")) subject.add( cfngenerator.SomeService_GeneratedClass(Parameter2="ami-23456789", Parameter1="az-2")) self.assertEqual(subject.get_resources_for_output(), output)
def testCreateClassWithSpec(self): name = 'AWS::SomeService::GeneratedClass' spec = json.loads('''{ "Documentation": "http://somewebpage", "Properties": { "Parameter1": { "Documentation": "http://somewebpage/parameter1", "PrimitiveType": "String", "Required": true, "UpdateType": "Immutable" }, "Parameter2": { "Documentation": "http://somewebpage/parameter2", "PrimitiveType": "String", "Required": false, "UpdateType": "Mutable" } } }''') cfngenerator.class_factory(name, spec) subject = cfngenerator.SomeService_GeneratedClass() self.assertIsInstance(subject, cfngenerator.GenericResource)
def testCreateClass(self): name = 'AWS::SomeService::GeneratedClass' spec = json.loads( '{}') # does not need to be anything. See later tests. cfngenerator.class_factory(name, spec) subject = cfngenerator.SomeService_GeneratedClass() self.assertIsInstance(subject, cfngenerator.GenericResource)
def testGeneratedClassOutput(self): name = 'AWS::SomeService::GeneratedClass' spec = json.loads('''{ "Documentation": "http://somewebpage", "Properties": { "Parameter1": { "Documentation": "http://somewebpage/parameter1", "PrimitiveType": "String", "Required": true, "UpdateType": "Immutable" }, "Parameter2": { "Documentation": "http://somewebpage/parameter2", "PrimitiveType": "String", "Required": false, "UpdateType": "Mutable" } } }''') output = yaml.dump( { 'Type': 'AWS::SomeService::GeneratedClass', 'Properties': { 'Parameter1': 'a value', 'Parameter2': 'another value' } }, default_flow_style=False) cfngenerator.class_factory(name, spec) subject = cfngenerator.SomeService_GeneratedClass( Parameter1='a value', Parameter2='another value') self.assertEqual(yaml.dump(dict(subject), default_flow_style=False), output)
def testGeneratedClassWithCorrectParameters(self): return cfngenerator.SomeService_GeneratedClass(Parameter1='a value', Parameter2='another value')