diff --git a/expandybird/expansion/expansion_test.py b/expandybird/expansion/expansion_test.py index d1b0e84f3..3bc52e452 100644 --- a/expandybird/expansion/expansion_test.py +++ b/expandybird/expansion/expansion_test.py @@ -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') diff --git a/expandybird/test/templates/no_properties_schema_defaults.py b/expandybird/test/templates/no_properties_schema_defaults.py new file mode 100644 index 000000000..8fd85dc2d --- /dev/null +++ b/expandybird/test/templates/no_properties_schema_defaults.py @@ -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"]} diff --git a/expandybird/test/templates/no_properties_schema_defaults.py.schema b/expandybird/test/templates/no_properties_schema_defaults.py.schema new file mode 100644 index 000000000..82f56a531 --- /dev/null +++ b/expandybird/test/templates/no_properties_schema_defaults.py.schema @@ -0,0 +1,5 @@ + +properties: + firewallname: + type: string + default: defaultname diff --git a/expandybird/test/templates/no_properties_schema_defaults.yaml b/expandybird/test/templates/no_properties_schema_defaults.yaml new file mode 100644 index 000000000..605413b65 --- /dev/null +++ b/expandybird/test/templates/no_properties_schema_defaults.yaml @@ -0,0 +1,6 @@ +imports: +- path: "no_properties_schema_defaults.py" + +resources: +- name: test-resource + type: no_properties_schema_defaults.py diff --git a/expandybird/test/templates/no_properties_schema_defaults_result.yaml b/expandybird/test/templates/no_properties_schema_defaults_result.yaml new file mode 100644 index 000000000..12af50849 --- /dev/null +++ b/expandybird/test/templates/no_properties_schema_defaults_result.yaml @@ -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