Incorrect inheritance of properties in capability objects

Change-Id: I0cda665d84548c879d7cd054e180548c1f45c58b
Related-Bug: 1533624
This commit is contained in:
Miguel Caballer
2016-01-13 13:01:03 +01:00
parent 9ed4657c9e
commit dbd4a1fcc8
2 changed files with 36 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ class CapabilityTypeDef(StatefulEntityType):
for prop, schema in props.items():
# add parent property if not overridden by children type
if not self.properties or \
prop not in self.properties.items():
prop not in self.properties.keys():
properties.append(PropertyDef(prop, None, schema))
return properties

View File

@@ -251,3 +251,38 @@ class PropertyTest(TestCase):
'attribute with invalid value "dunno". The '
'value must be one of "%s".') % valid_values)
self.assertEqual(expected_message, str(error))
def test_capability_proprety_inheritance(self):
from toscaparser.nodetemplate import NodeTemplate
tosca_custom_def = '''
tosca.capabilities.ScalableNew:
derived_from: tosca.capabilities.Scalable
properties:
max_instances:
type: integer
default: 0
required: no
tosca.nodes.ComputeNew:
derived_from: tosca.nodes.Compute
capabilities:
scalable:
type: tosca.capabilities.ScalableNew
'''
tosca_node_template = '''
node_templates:
compute_instance:
type: tosca.nodes.ComputeNew
capabilities:
scalable:
properties:
min_instances: 1
'''
nodetemplates = yamlparser.\
simple_parse(tosca_node_template)['node_templates']
custom_def = yamlparser.simple_parse(tosca_custom_def)
name = list(nodetemplates.keys())[0]
tpl = NodeTemplate(name, nodetemplates, custom_def)
tpl.validate()