diff options
Diffstat (limited to 'app/tests/test_substitution_rule.py')
-rw-r--r-- | app/tests/test_substitution_rule.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/tests/test_substitution_rule.py b/app/tests/test_substitution_rule.py new file mode 100644 index 0000000..aec3745 --- /dev/null +++ b/app/tests/test_substitution_rule.py @@ -0,0 +1,31 @@ +import unittest +from tests.utils.test_utils import * + + +class TestSubstitutionRuleMethods(unittest.TestCase): + + def test_update_pointer(self): + template = init_template() + sub_template = init_sub_template() + src_node = sub_template.node_dict.get('nodeName') + target_node = template.node_dict.get('node2') + sub_sec = {'node_type': 'nodeTypeName', + 'requirements': {'substituteRequirement': ['node2', 'dummyRequirement']}, + 'capabilities': {'substituteCapability': ['node2', 'capabilityName']}} + sub_template._parse_substitution(template.db, sub_sec) + rules = sub_template.sub_rules + self.assertIsNone(src_node.properties[rules[0].property].sub_pointer) + self.assertIsNone(src_node.capabilities[rules[1].item].sub_pointer) + self.assertIsNone(src_node.capabilities[rules[1].item].properties['capabilityProperty'].sub_pointer) + self.assertIsNone(src_node.requirements[0].sub_pointer) + rules[0]._update_pointer(src_node, sub_template) + self.assertIsNotNone(src_node.properties[rules[0].property].sub_pointer) + self.assertEqual(src_node.properties[rules[0].property].sub_pointer, sub_template.inputs[rules[0].property]) + rules[1]._update_pointer(src_node, template) + self.assertIsNotNone(src_node.capabilities[rules[1].item].sub_pointer) + self.assertIsNotNone(src_node.capabilities[rules[1].item].properties['capabilityProperty'].sub_pointer) + self.assertEqual(src_node.capabilities[rules[1].item].sub_pointer, target_node.capabilities[rules[1].value[1]]) + self.assertEqual(src_node.capabilities[rules[1].item].properties['capabilityProperty'].sub_pointer, target_node.capabilities[rules[1].value[1]].properties['capabilityProperty']) + rules[2]._update_pointer(src_node, template) + self.assertIsNotNone(src_node.requirements[0].sub_pointer) + self.assertEqual(src_node.requirements[0].sub_pointer, target_node.requirements[0]) |