Test for schema that sets defaults on resource with no properties block

pull/167/head^2
Graham Welch 10 years ago
parent e87875f683
commit 038b6ef2b3

@ -483,6 +483,22 @@ class ExpansionTest(unittest.TestCase):
self.assertEquals(result_file, expanded_template)
def testNoPropertiesSchemaDefaults(self):
template = ReadTestFile('no_properties_schema_defaults.yaml')
imports = {}
imports['no_properties_schema_defaults.py'] = ReadTestFile(
'no_properties_schema_defaults.py')
imports['no_properties_schema_defaults.py.schema'] = ReadTestFile(
'no_properties_schema_defaults.py.schema')
expanded_template = expansion.Expand(
template, imports, validate_schema=True)
result_file = ReadTestFile('no_properties_schema_defaults_result.yaml')
self.assertEquals(result_file, expanded_template)
def testNestedTemplateSchema(self):
template = ReadTestFile('use_helper.yaml')

@ -0,0 +1,11 @@
"""Basic firewall template."""
def GenerateConfig(evaluation_context):
return """
resources:
- type: compute.v1.firewall
name: %(master)s-firewall
properties:
sourceRanges: [ "0.0.0.0/0" ]
""" % {"master": evaluation_context.properties["firewallname"]}

@ -0,0 +1,5 @@
properties:
firewallname:
type: string
default: defaultname

@ -0,0 +1,6 @@
imports:
- path: "no_properties_schema_defaults.py"
resources:
- name: test-resource
type: no_properties_schema_defaults.py

@ -0,0 +1,16 @@
config:
resources:
- name: defaultname-firewall
properties:
sourceRanges:
- 0.0.0.0/0
type: compute.v1.firewall
layout:
resources:
- name: test-resource
properties:
firewallname: defaultname
resources:
- name: defaultname-firewall
type: compute.v1.firewall
type: no_properties_schema_defaults.py
Loading…
Cancel
Save