Incorrect inheritance of properties in capability objects
Change-Id: I0cda665d84548c879d7cd054e180548c1f45c58b Related-Bug: 1533624
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user