diff options
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/tests')
4 files changed, 37 insertions, 10 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/data/topology_template/subsystem.yaml b/tosca2heat/tosca-parser/toscaparser/tests/data/topology_template/subsystem.yaml index b27e698..99d645b 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/data/topology_template/subsystem.yaml +++ b/tosca2heat/tosca-parser/toscaparser/tests/data/topology_template/subsystem.yaml @@ -12,12 +12,15 @@ topology_template: inputs: mq_server_ip: type: string + required: true description: IP address of the message queuing server to receive messages from. receiver_port: type: string + required: true description: Port to be used for receiving messages. my_cpus: type: integer + default: 2 description: Number of CPUs for the server. constraints: - valid_values: [ 1, 2, 4, 8 ] diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py b/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py index 0f1a33e..cbd4e3b 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py @@ -34,6 +34,11 @@ class TopologyTemplateTest(TestCase): self.topo = TopologyTemplate(self.topo_tpl, self._get_all_custom_def()) + self.tosca_system_tpl_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/system.yaml") + self.system_template = ToscaTemplate(self.tosca_system_tpl_path) + def _get_custom_def(self, type_definition): custom_defs = {} for definition in self.imports: diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py b/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py index 9c2ce35..358bf28 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py @@ -189,8 +189,9 @@ class ToscaDefTest(TestCase): self.assertIn(ifaces.LIFECYCLE_SHORTNAME, root_node.interfaces) def test_artifacts(self): + self.assertEqual(artif_root_type.parent_type, None) self.assertEqual('tosca.artifacts.Root', - artif_file_type.parent_type) + artif_file_type.parent_type.type) self.assertEqual({}, artif_file_type.parent_artifacts) self.assertEqual(sorted(['tosca.artifacts.Root'], key=lambda x: str(x)), @@ -199,7 +200,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.artifacts.Implementation', - artif_bash_type.parent_type) + artif_bash_type.parent_type.type) self.assertEqual({'tosca.artifacts.Implementation': {'derived_from': 'tosca.artifacts.Root', 'description': @@ -213,7 +214,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.artifacts.Implementation', - artif_python_type.parent_type) + artif_python_type.parent_type.type) self.assertEqual({'tosca.artifacts.Implementation': {'derived_from': 'tosca.artifacts.Root', 'description': @@ -228,7 +229,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.artifacts.Deployment.Image', - artif_container_docker_type.parent_type) + artif_container_docker_type.parent_type.type) self.assertEqual({'tosca.artifacts.Deployment': {'derived_from': 'tosca.artifacts.Root', 'description': @@ -245,7 +246,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.artifacts.Deployment.Image', - artif_vm_iso_type.parent_type) + artif_vm_iso_type.parent_type.type) self.assertEqual({'tosca.artifacts.Deployment': {'derived_from': 'tosca.artifacts.Root', 'description': @@ -264,7 +265,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.artifacts.Deployment.Image', - artif_vm_qcow2_type.parent_type) + artif_vm_qcow2_type.parent_type.type) self.assertEqual({'tosca.artifacts.Deployment': {'derived_from': 'tosca.artifacts.Root', 'description': @@ -283,8 +284,9 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) def test_policies(self): + self.assertEqual(policy_root_type.parent_type, None) self.assertEqual('tosca.policies.Root', - policy_placement_type.parent_type) + policy_placement_type.parent_type.type) self.assertEqual({}, policy_placement_type.parent_policies) self.assertEqual(sorted(['tosca.policies.Root', 'The TOSCA Policy Type definition that is ' @@ -296,7 +298,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.policies.Root', - policy_scaling_type.parent_type) + policy_scaling_type.parent_type.type) self.assertEqual({}, policy_scaling_type.parent_policies) self.assertEqual(sorted(['tosca.policies.Root', 'The TOSCA Policy Type definition that is ' @@ -308,7 +310,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.policies.Root', - policy_update_type.parent_type) + policy_update_type.parent_type.type) self.assertEqual({}, policy_update_type.parent_policies) self.assertEqual(sorted(['tosca.policies.Root', 'The TOSCA Policy Type definition that is ' @@ -320,7 +322,7 @@ class ToscaDefTest(TestCase): key=lambda x: str(x))) self.assertEqual('tosca.policies.Root', - policy_performance_type.parent_type) + policy_performance_type.parent_type.type) self.assertEqual({}, policy_performance_type.parent_policies) self.assertEqual(sorted(['tosca.policies.Root', 'The TOSCA Policy Type definition that is ' diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatpl.py b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatpl.py index 3fd49bf..ac55059 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatpl.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatpl.py @@ -134,6 +134,19 @@ class ToscaTemplateTest(TestCase): self.assertEqual('Linux', os_props['type'].value) self.assertEqual('Linux', os_type_prop) + def test_node_inheritance_type(self): + wordpress_node = [ + node for node in self.tosca.nodetemplates + if node.name == 'wordpress'][0] + self.assertTrue( + wordpress_node.is_derived_from("tosca.nodes.WebApplication")) + self.assertTrue( + wordpress_node.is_derived_from("tosca.nodes.Root")) + self.assertFalse( + wordpress_node.is_derived_from("tosca.policies.Root")) + self.assertFalse( + wordpress_node.is_derived_from("tosca.groups.Root")) + def test_outputs(self): self.assertEqual( ['website_url'], @@ -211,6 +224,8 @@ class ToscaTemplateTest(TestCase): for key in relation.keys(): rel_tpl = relation.get(key).get_relationship_template() if rel_tpl: + 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 +743,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") |