Solves the incorrect inheritance of attributes in NodeType
Also remove unnecesary sort in some tests. Change-Id: Ie67d88f17753fa5225a288a629075cf67c803baa Related-Bug: 1540799
This commit is contained in:
@@ -66,7 +66,7 @@ class StatefulEntityType(EntityType):
|
|||||||
|
|
||||||
def get_attributes_def_objects(self):
|
def get_attributes_def_objects(self):
|
||||||
'''Return a list of attribute definition objects.'''
|
'''Return a list of attribute definition objects.'''
|
||||||
attrs = self.get_value(self.ATTRIBUTES)
|
attrs = self.get_value(self.ATTRIBUTES, parent=True)
|
||||||
if attrs:
|
if attrs:
|
||||||
return [AttributeDef(attr, None, schema)
|
return [AttributeDef(attr, None, schema)
|
||||||
for attr, schema in attrs.items()]
|
for attr, schema in attrs.items()]
|
||||||
|
|||||||
28
toscaparser/tests/data/test_attributes_inheritance.yaml
Normal file
28
toscaparser/tests/data/test_attributes_inheritance.yaml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||||
|
|
||||||
|
description: TOSCA simple profile to test the attribute inheritance
|
||||||
|
|
||||||
|
imports:
|
||||||
|
- custom_types/compute_with_prop.yaml
|
||||||
|
|
||||||
|
topology_template:
|
||||||
|
|
||||||
|
node_templates:
|
||||||
|
|
||||||
|
server:
|
||||||
|
type: tosca.nodes.ComputeWithProp
|
||||||
|
properties:
|
||||||
|
test: yes
|
||||||
|
capabilities:
|
||||||
|
host:
|
||||||
|
properties:
|
||||||
|
num_cpus: 1
|
||||||
|
mem_size: 1 GB
|
||||||
|
os:
|
||||||
|
properties:
|
||||||
|
type: linux
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
server_ip:
|
||||||
|
value: { get_attribute: [ server, public_address ] }
|
||||||
|
|
||||||
@@ -64,15 +64,15 @@ class ToscaDefTest(TestCase):
|
|||||||
|
|
||||||
def test_capabilities(self):
|
def test_capabilities(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(['tosca.capabilities.Container',
|
['tosca.capabilities.Container',
|
||||||
'tosca.capabilities.Node',
|
'tosca.capabilities.Node',
|
||||||
'tosca.capabilities.OperatingSystem',
|
'tosca.capabilities.OperatingSystem',
|
||||||
'tosca.capabilities.network.Bindable',
|
'tosca.capabilities.Scalable',
|
||||||
'tosca.capabilities.Scalable']),
|
'tosca.capabilities.network.Bindable'],
|
||||||
sorted([c.type for c in compute_type.get_capabilities_objects()]))
|
sorted([c.type for c in compute_type.get_capabilities_objects()]))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted(['tosca.capabilities.Node',
|
['tosca.capabilities.Node',
|
||||||
'tosca.capabilities.network.Linkable']),
|
'tosca.capabilities.network.Linkable'],
|
||||||
sorted([c.type for c in network_type.get_capabilities_objects()]))
|
sorted([c.type for c in network_type.get_capabilities_objects()]))
|
||||||
endpoint_properties = ['initiator', 'network_name', 'port',
|
endpoint_properties = ['initiator', 'network_name', 'port',
|
||||||
'port_name', 'ports', 'protocol',
|
'port_name', 'ports', 'protocol',
|
||||||
@@ -154,7 +154,8 @@ class ToscaDefTest(TestCase):
|
|||||||
|
|
||||||
def test_attributes_def(self):
|
def test_attributes_def(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
['networks', 'ports', 'private_address', 'public_address'],
|
['networks', 'ports', 'private_address', 'public_address',
|
||||||
|
'state', 'tosca_id', 'tosca_name'],
|
||||||
sorted(compute_type.get_attributes_def().keys()))
|
sorted(compute_type.get_attributes_def().keys()))
|
||||||
|
|
||||||
def test_requirements(self):
|
def test_requirements(self):
|
||||||
@@ -171,8 +172,8 @@ class ToscaDefTest(TestCase):
|
|||||||
|
|
||||||
def test_relationship(self):
|
def test_relationship(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted([('tosca.relationships.HostedOn', 'tosca.nodes.Compute'),
|
[('tosca.relationships.DependsOn', 'tosca.nodes.Root'),
|
||||||
('tosca.relationships.DependsOn', 'tosca.nodes.Root')]),
|
('tosca.relationships.HostedOn', 'tosca.nodes.Compute')],
|
||||||
sorted([(relation.type, node.type) for
|
sorted([(relation.type, node.type) for
|
||||||
relation, node in component_type.relationship.items()]))
|
relation, node in component_type.relationship.items()]))
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
|
|||||||
@@ -698,3 +698,9 @@ class ToscaTemplateTest(TestCase):
|
|||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
"data/test_node_filter.yaml")
|
"data/test_node_filter.yaml")
|
||||||
ToscaTemplate(tosca_tpl)
|
ToscaTemplate(tosca_tpl)
|
||||||
|
|
||||||
|
def test_attributes_inheritance(self):
|
||||||
|
tosca_tpl = os.path.join(
|
||||||
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
"data/test_attributes_inheritance.yaml")
|
||||||
|
ToscaTemplate(tosca_tpl)
|
||||||
|
|||||||
Reference in New Issue
Block a user