diff options
author | Betzer, Rony (rb844h) <rb844h@intl.att.com> | 2018-10-04 16:47:13 +0300 |
---|---|---|
committer | Michael Lando <michael.lando@intl.att.com> | 2018-10-10 10:37:19 +0000 |
commit | 2236f9d810af0d2ef480eafbfa2abcc2b3cd932e (patch) | |
tree | 02a352f8aabcfee8a18f654b72d20919af84e43a /app/tests/test_node_templates.py | |
parent | a1cce5a9df1415309828944da3aa8a56e8f7d52e (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_node_templates.py')
-rw-r--r-- | app/tests/test_node_templates.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/app/tests/test_node_templates.py b/app/tests/test_node_templates.py new file mode 100644 index 0000000..15d5480 --- /dev/null +++ b/app/tests/test_node_templates.py @@ -0,0 +1,71 @@ +import unittest +from tests.utils.test_utils import init_template +from toscalib.templates.node import Node + + +class TestNodeTemplateMethods(unittest.TestCase): + + def test_instantiate_with_type(self): + template = init_template() + node = Node(template, 'myNode', template.db.NODE_TYPES.get('nodeTypeName')) + self.assertEqual(1, len(node.attributes)) + node._instatiateWithType(template.db.NODE_TYPES.get('substituteNodeType')) + self.assertEqual(0, len(node.attributes)) + + def test_parse_pre_defined_content(self): + template = init_template() + node = Node(template, 'myNode', template.db.NODE_TYPES.get('nodeTypeName')) + self.assertIsNone(node.properties.get('propertyName').value) + prop_sec = {'properties': {'propertyName': 'template_value'}} + node._parse_pre_defined_content(prop_sec) + self.assertEqual('template_value', node.properties.get('propertyName').value.value) + + # TODO uncomment after merging ecomp latest code + # def test_update_get_node_name_property_value(self): + # template = init_template() + # node = Node(template, 'myNode', template.db.NODE_TYPES.get('nodeTypeName')) + # prop_sec = {'properties': {'propertyName': '__GET_NODE_NAME__'}} + # node._parse_pre_defined_content(prop_sec) + # self.assertEqual('__GET_NODE_NAME__', node.properties.get('propertyName').value.value) + # node._update_get_node_name() + # self.assertEqual('myNode', node.properties.get('propertyName').value.value) + + # TODO uncomment after merging ecomp latest code + # def test_update_get_node_name_capability_property_value(self): + # template = init_template() + # node = Node(template, 'myNode', template.db.NODE_TYPES.get('nodeTypeName')) + # prop_sec = {'capabilities': {'capabilityName': {'properties': {'capabilityProperty': '__GET_NODE_NAME__'}}}} + # node._parse_pre_defined_content(prop_sec) + # self.assertEqual('__GET_NODE_NAME__', node._get_capability_property('capabilityName', 'capabilityProperty').value.value) + # node._update_get_node_name() + # self.assertEqual('myNode', node._get_capability_property('capabilityName', 'capabilityProperty').value.value) + + def test_update_prefix(self): + template = init_template() + node = template.node_dict.get('nodeName') + prop_sec = {'properties': {'propertyName': {'get_input': 'inputName'}}, 'capabilities': {'capabilityName': {'properties': {'capabilityProperty': {'get_property': ['nodeName', 'propertyName']}}}}} + node._parse_pre_defined_content(prop_sec) + node._update_prefix('PREFIX_') + self.assertEqual('PREFIX_nodeName', node.name) + self.assertEqual('PREFIX_nodeName', node.id.value.function.extra_data[0]) + self.assertEqual('PREFIX_inputName', node.properties.get('propertyName').value.function.target_property) + self.assertEqual('PREFIX_nodeName', node._get_capability_property('capabilityName', 'capabilityProperty').value.function.extra_data[0]) + + def test_verify_functions(self): + template = init_template() + node = template.node_dict.get('nodeName') + prop_sec = {'properties': {'propertyName': {'get_input': 'inputName'}}, 'capabilities': {'capabilityName': {'properties': {'capabilityProperty': {'get_property': ['nodeName', 'propertyName']}}}}} + node._parse_pre_defined_content(prop_sec) + self.assertIsNone(node.properties.get('propertyName').value.function.value_from_item) + self.assertIsNone(node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_item) + self.assertIsNone(node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_node) + node._verify_functions() + self.assertIsNotNone(node.properties.get('propertyName').value.function.value_from_item) + self.assertIsNotNone(node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_item) + self.assertIsNotNone(node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_node) + self.assertEqual(template.inputs.get('inputName'), node.properties.get('propertyName').value.function.value_from_item) + self.assertEqual(node.properties.get('propertyName'), node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_item) + self.assertEqual(node, node._get_capability_property('capabilityName', 'capabilityProperty').value.function.value_from_node) + + + |