The relationship type's parent_type definition is not complete 55/15555/1
authorshangxdy <shang.xiaodong@zte.com.cn>
Tue, 14 Jun 2016 17:40:50 +0000 (01:40 +0800)
committershangxdy <shang.xiaodong@zte.com.cn>
Tue, 14 Jun 2016 17:40:50 +0000 (01:40 +0800)
1. Relationship type define parent_type, but it shall include custom def,
so the method of is_derived_from in group entity may be error when it's called.
2. The bug will submit to openstack community.

Change-Id: Ia12b18543e3b1d28bfb946abd11b546a9eba9669
JIRA: PARSER-55
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py
tosca2heat/tosca-parser/toscaparser/tests/test_toscatpl.py

index 9462d38..25440ca 100644 (file)
@@ -26,7 +26,7 @@ class RelationshipType(StatefulEntityType):
         '''Return a relationship this reletionship is derived from.'''
         prel = self.derived_from(self.defs)
         if prel:
-            return RelationshipType(prel)
+            return RelationshipType(prel, self.custom_def)
 
     @property
     def valid_target_types(self):
index 3fd49bf..564f4cd 100644 (file)
@@ -211,6 +211,10 @@ class ToscaTemplateTest(TestCase):
                 for key in relation.keys():
                     rel_tpl = relation.get(key).get_relationship_template()
                     if rel_tpl:
+                        self.assertEqual(
+                            rel_tpl[0].type, "tosca.relationships.ConnectsTo")
+                        self.assertTrue(rel_tpl[0].is_derived_from(
+                            "tosca.relationships.Root"))
                         interfaces = rel_tpl[0].interfaces
                         for interface in interfaces:
                             self.assertEqual(config_interface,
@@ -728,5 +732,7 @@ class ToscaTemplateTest(TestCase):
             "data/test_tosca_custom_rel_with_script.yaml")
         tosca = ToscaTemplate(tosca_tpl)
         rel = tosca.relationship_templates[0]
+        self.assertEqual(rel.type, "tosca.relationships.HostedOn")
+        self.assertTrue(rel.is_derived_from("tosca.relationships.Root"))
         self.assertEqual(len(rel.interfaces), 1)
         self.assertEqual(rel.interfaces[0].type, "Configure")