Merge "Fail to parse if relationship is not defined in requirements."
This commit is contained in:
commit
3242ea550e
@ -85,9 +85,10 @@ class NodeType(StatefulEntityType):
|
|||||||
_get_node_type_by_cap(captype))
|
_get_node_type_by_cap(captype))
|
||||||
keyword = key
|
keyword = key
|
||||||
node_type = value
|
node_type = value
|
||||||
rtype = RelationshipType(relation, keyword, self.custom_def)
|
rtype = RelationshipType(relation, keyword,
|
||||||
relatednode = NodeType(node_type, self.custom_def)
|
self.custom_def)
|
||||||
relationship[rtype] = relatednode
|
relatednode = NodeType(node_type, self.custom_def)
|
||||||
|
relationship[rtype] = relatednode
|
||||||
return relationship
|
return relationship
|
||||||
|
|
||||||
def _get_node_type_by_cap(self, cap):
|
def _get_node_type_by_cap(self, cap):
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Test NodeType which requirements has no relationship.
|
||||||
|
|
||||||
|
node_types:
|
||||||
|
sample.SC:
|
||||||
|
derived_from: tosca.nodes.SoftwareComponent
|
||||||
|
requirements:
|
||||||
|
- custom_host:
|
||||||
|
capability: tosca.capabilities.Attachment
|
||||||
|
node: tosca.nodes.Compute
|
||||||
|
|
||||||
|
topology_template:
|
||||||
|
node_templates:
|
||||||
|
SampleSC1:
|
||||||
|
type: sample.SC
|
||||||
|
requirements:
|
||||||
|
- custom_host: Compute1
|
||||||
|
Compute1:
|
||||||
|
type: tosca.nodes.Compute
|
||||||
|
SC2:
|
||||||
|
type: tosca.nodes.SoftwareComponent
|
||||||
|
requirements:
|
||||||
|
- host: Compute2
|
||||||
|
Compute2:
|
||||||
|
type: tosca.nodes.Compute
|
@ -148,6 +148,37 @@ class ToscaTemplateTest(TestCase):
|
|||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
wordpress_node.is_derived_from("tosca.policies.Root"))
|
wordpress_node.is_derived_from("tosca.policies.Root"))
|
||||||
|
|
||||||
|
def test_nodetype_without_relationship(self):
|
||||||
|
# Nodes that contain "relationship" in "requirements"
|
||||||
|
depend_node_types = (
|
||||||
|
"tosca.nodes.SoftwareComponent",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Nodes that do not contain "relationship" in "requirements"
|
||||||
|
non_depend_node_types = (
|
||||||
|
"tosca.nodes.Compute",
|
||||||
|
"sample.SC",
|
||||||
|
)
|
||||||
|
|
||||||
|
tosca_tpl = os.path.join(
|
||||||
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
"data/test_nodetype_without_relationship.yaml")
|
||||||
|
tosca = ToscaTemplate(tosca_tpl)
|
||||||
|
|
||||||
|
nodetemplates = tosca.nodetemplates
|
||||||
|
for node in nodetemplates:
|
||||||
|
node_depend = node.related_nodes
|
||||||
|
if node_depend:
|
||||||
|
self.assertIn(
|
||||||
|
node.type,
|
||||||
|
depend_node_types
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.assertIn(
|
||||||
|
node.type,
|
||||||
|
non_depend_node_types
|
||||||
|
)
|
||||||
|
|
||||||
def test_outputs(self):
|
def test_outputs(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
['website_url'],
|
['website_url'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user