Solves the incorrect inheritance of attributes and requirements of tosca.nodes.Root

It also updates the related tests since now the Root attributes and requirements are returned in the proper functions.

Change-Id: If01f49969223c569bdbe2d954f3d1a65b95250ce
Related-Bug: 1540833
This commit is contained in:
Miguel Caballer
2016-02-02 16:37:06 +01:00
parent f73c803211
commit 7446571f71
3 changed files with 16 additions and 9 deletions

View File

@@ -92,9 +92,7 @@ class EntityType(object):
if parent:
p = self.parent_type
if p:
while p.type != 'tosca.nodes.Root':
if p and p.type == 'tosca.nodes.Root':
break
while p:
if ndtype in p.defs:
# get the parent value
parent_value = p.defs[ndtype]

View File

@@ -65,13 +65,15 @@ class ToscaDefTest(TestCase):
def test_capabilities(self):
self.assertEqual(
sorted(['tosca.capabilities.Container',
'tosca.capabilities.Node',
'tosca.capabilities.OperatingSystem',
'tosca.capabilities.network.Bindable',
'tosca.capabilities.Scalable']),
sorted([c.type for c in compute_type.get_capabilities_objects()]))
self.assertEqual(
['tosca.capabilities.network.Linkable'],
[c.type for c in network_type.get_capabilities_objects()])
sorted(['tosca.capabilities.Node',
'tosca.capabilities.network.Linkable']),
sorted([c.type for c in network_type.get_capabilities_objects()]))
endpoint_properties = ['initiator', 'network_name', 'port',
'port_name', 'ports', 'protocol',
'secure', 'url_path']
@@ -159,14 +161,20 @@ class ToscaDefTest(TestCase):
self.assertEqual(
[{'host': {'capability': 'tosca.capabilities.Container',
'node': 'tosca.nodes.Compute',
'relationship': 'tosca.relationships.HostedOn'}}],
'relationship': 'tosca.relationships.HostedOn'}},
{'dependency': {'capability': 'tosca.capabilities.Node',
'node': 'tosca.nodes.Root',
'occurrences': [0, 'UNBOUNDED'],
'relationship': 'tosca.relationships.DependsOn'}}
],
[r for r in component_type.requirements])
def test_relationship(self):
self.assertEqual(
[('tosca.relationships.HostedOn', 'tosca.nodes.Compute')],
[(relation.type, node.type) for
relation, node in component_type.relationship.items()])
sorted([('tosca.relationships.HostedOn', 'tosca.nodes.Compute'),
('tosca.relationships.DependsOn', 'tosca.nodes.Root')]),
sorted([(relation.type, node.type) for
relation, node in component_type.relationship.items()]))
self.assertIn(
('tosca.relationships.HostedOn', ['tosca.capabilities.Container']),
[(relation.type, relation.valid_target_types) for

View File

@@ -186,6 +186,7 @@ class ToscaTemplateTest(TestCase):
compute_type = NodeType(tpl.type)
self.assertEqual(
sorted(['tosca.capabilities.Container',
'tosca.capabilities.Node',
'tosca.capabilities.OperatingSystem',
'tosca.capabilities.network.Bindable',
'tosca.capabilities.Scalable']),