Merge "Bugfix for RelationshipTemplate._create_relationship_properties method to get the properties of the "explicit relationships""
This commit is contained in:
commit
3890832640
@ -46,6 +46,13 @@ class RelationshipTemplate(EntityTemplate):
|
||||
props = []
|
||||
properties = {}
|
||||
relationship = self.entity_tpl.get('relationship')
|
||||
|
||||
if not relationship:
|
||||
for value in self.entity_tpl.values():
|
||||
if isinstance(value, dict):
|
||||
relationship = value.get('relationship')
|
||||
break
|
||||
|
||||
if relationship:
|
||||
properties = self.type_definition.get_value(self.PROPERTIES,
|
||||
relationship) or {}
|
||||
|
@ -322,7 +322,43 @@ class PropertyTest(TestCase):
|
||||
custom_def_snippet=None):
|
||||
nodetemplates = yamlparser.\
|
||||
simple_parse(tpl_snippet)['node_templates']
|
||||
custom_def = yamlparser.simple_parse(custom_def_snippet)
|
||||
custom_def = []
|
||||
if custom_def_snippet:
|
||||
custom_def = yamlparser.simple_parse(custom_def_snippet)
|
||||
name = list(nodetemplates.keys())[0]
|
||||
tpl = NodeTemplate(name, nodetemplates, custom_def)
|
||||
return tpl
|
||||
|
||||
def test_explicit_relationship_proprety(self):
|
||||
|
||||
tosca_node_template = '''
|
||||
node_templates:
|
||||
|
||||
client_node:
|
||||
type: tosca.nodes.Compute
|
||||
requirements:
|
||||
- local_storage:
|
||||
node: my_storage
|
||||
relationship:
|
||||
type: AttachesTo
|
||||
properties:
|
||||
location: /mnt/disk
|
||||
|
||||
my_storage:
|
||||
type: tosca.nodes.BlockStorage
|
||||
properties:
|
||||
size: 1 GB
|
||||
'''
|
||||
|
||||
expected_properties = ['location']
|
||||
|
||||
nodetemplates = yamlparser.\
|
||||
simple_parse(tosca_node_template)['node_templates']
|
||||
tpl = NodeTemplate('client_node', nodetemplates, [])
|
||||
|
||||
self.assertIsNone(tpl.validate())
|
||||
rel_tpls = []
|
||||
for relationship, trgt in tpl.relationships.items():
|
||||
rel_tpls.extend(trgt.get_relationship_template())
|
||||
self.assertEqual(expected_properties,
|
||||
sorted(rel_tpls[0].get_properties().keys()))
|
||||
|
Loading…
Reference in New Issue
Block a user