summaryrefslogtreecommitdiffstats
path: root/app/tests/test_topology_template.py
diff options
context:
space:
mode:
authorBetzer, Rony (rb844h) <rb844h@intl.att.com>2018-10-04 16:47:13 +0300
committerMichael Lando <michael.lando@intl.att.com>2018-10-10 10:37:19 +0000
commit2236f9d810af0d2ef480eafbfa2abcc2b3cd932e (patch)
tree02a352f8aabcfee8a18f654b72d20919af84e43a /app/tests/test_topology_template.py
parenta1cce5a9df1415309828944da3aa8a56e8f7d52e (diff)
UT coverage report with tox and virtualenv
UT coverage report with tox and virtualenv Change-Id: I90d6d4099e8cf43201082d5094865ee78c0bad9e Issue-ID: SDC-1756 Signed-off-by: Betzer, Rony (rb844h) <rb844h@intl.att.com>
Diffstat (limited to 'app/tests/test_topology_template.py')
-rw-r--r--app/tests/test_topology_template.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/tests/test_topology_template.py b/app/tests/test_topology_template.py
new file mode 100644
index 0000000..8e7da5a
--- /dev/null
+++ b/app/tests/test_topology_template.py
@@ -0,0 +1,35 @@
+import unittest
+from toscalib.templates.topology import ToscaTopology
+from tests.utils.test_utils import init_template
+
+
+class TestTopologyTemplateMethods(unittest.TestCase):
+
+ def test_update_mapping_template_pointer(self):
+ template = init_template()
+ sub_sec = {'node_type': 'substituteNodeType', 'capabilities': {'substituteCapability': ['nodeName', 'capabilityName']}}
+ sub_type = template.db.NODE_TYPES.get('substituteNodeType')
+ self.assertIsNone(sub_type.mapping_template)
+ template._parse_substitution(template.db, sub_sec)
+ self.assertIsNotNone(sub_type.mapping_template)
+ self.assertEqual(sub_type.mapping_template, template)
+
+ def test_parse_substitution(self):
+ template = init_template()
+ sub_sec = {'node_type': 'substituteNodeType', 'requirements': {'substituteRequirement': ['node2', 'dummyRequirement']}, 'capabilities': {'substituteCapability': ['nodeName', 'capabilityName']}}
+ self.assertIsNone(template.sub_type)
+ self.assertEqual(len(template.sub_rules), 0)
+ template._parse_substitution(template.db, sub_sec)
+ self.assertEqual(template.sub_type, 'substituteNodeType')
+ self.assertEqual(len(template.sub_rules), 3)
+
+ def test_prepare_output(self):
+ template = ToscaTopology('topoName')
+ res = template._prepare_output()
+ self.assertEqual(res, {'00_YAMLORDER_tosca_definitions_version': 'tosca_simple_yaml_1_0_0', '14_YAMLORDER_topology_template': {}})
+ template = init_template()
+ res = template._prepare_output()
+ self.assertEqual(res, {'00_YAMLORDER_tosca_definitions_version': 'tosca_simple_yaml_1_0_0', '14_YAMLORDER_topology_template': {'11_YAMLORDER_inputs': {'inputName': {'00_YAMLORDER_type': 'string'}},
+ '13_YAMLORDER_node_templates': {'node2': {'00_YAMLORDER_type': 'nodeTypeName', '01_YAMLORDER_properties': {'propertyName': None},'05_YAMLORDER_requirements': [{'dummyRequirement': 'nodeName'}]},
+ 'nodeName': {'00_YAMLORDER_type': 'nodeTypeName', '01_YAMLORDER_properties': {'propertyName': None}}}}})
+