diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2019-04-22 13:48:41 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2019-04-22 15:09:21 +0800 |
commit | 7bea3b7c8b9c5d659973790486d38e57d9ad6939 (patch) | |
tree | 0b79c9226f412e74164a4e504759e9fc53b390c6 | |
parent | 3ba8f3a9d7a51b0864f22ef6b2be046fd6466b7d (diff) |
toscaparser: Support deriving from capability types of no property
Change-Id: I259a43b72a4dd3c74ad54a250ada9f913b5ce67b
Issue-ID: PARSER-188
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py | 2 | ||||
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/tests/test_properties.py | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py index 23c5afc..c37aa9d 100644 --- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py +++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py @@ -35,7 +35,7 @@ class CapabilityTypeDef(StatefulEntityType): parent_properties = {} if self.parent_capabilities: for type, value in self.parent_capabilities.items(): - parent_properties[type] = value.get('properties') + parent_properties[type] = value.get('properties', {}) if self.properties: for prop, schema in self.properties.items(): properties.append(PropertyDef(prop, None, schema)) diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py b/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py index 6b95537..faa8af4 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_properties.py @@ -314,6 +314,31 @@ class PropertyTest(TestCase): num_cpus: 1 ''' + tosca_custom_def_example3 = ''' + tosca.capabilities.New: + derived_from: tosca.capabilities.Node + properties: + test_case: + type: integer + required: yes + + tosca.nodes.ComputeNew: + derived_from: tosca.nodes.Compute + capabilities: + scalable: + type: tosca.capabilities.New + ''' + + tosca_node_template_example3 = ''' + node_templates: + compute_instance: + type: tosca.nodes.ComputeNew + capabilities: + scalable: + properties: + test_case: 1 + ''' + tpl1 = self._get_nodetemplate(tosca_node_template_example1, tosca_custom_def_example1) self.assertIsNone(tpl1.validate()) @@ -322,6 +347,10 @@ class PropertyTest(TestCase): tosca_custom_def_example2) self.assertIsNone(tpl2.validate()) + tpl3 = self._get_nodetemplate(tosca_node_template_example3, + tosca_custom_def_example3) + self.assertIsNone(tpl3.validate()) + def _get_nodetemplate(self, tpl_snippet, custom_def_snippet=None): nodetemplates = yamlparser.\ |