From 7f2bbc7c5913a39d49fdc6533c708939b47a9233 Mon Sep 17 00:00:00 2001 From: shangxdy Date: Thu, 8 Dec 2016 11:42:45 +0800 Subject: Add output validation test case for substitution. According to currently implementation, add new test case for substitution mappings output validation: 1. Unknown output; 2. Missing required output. JIRA:PARSER-116 Change-Id: I84dc80c2bc6fd8b63dd7c4ddf0b81dc5148a4ceb Signed-off-by: shangxdy --- .../toscaparser/tests/test_topology_template.py | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py') diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py b/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py index eb8d589..0c26b67 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py @@ -262,3 +262,52 @@ class TopologyTemplateTest(TestCase): lambda: ToscaTemplate(tpl_path1)) exception.ExceptionCollector.assertExceptionMessage( exception.MissingRequiredInputError, errormsg) + + def test_system_with_unknown_output_validation(self): + tpl_path0 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/" + "system_invalid_unknown_output.yaml") + tpl_path1 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/" + "transactionsubsystem_invalid_unknown_output.yaml") + errormsg = _('Unknown output "my_cpu_output" in SubstitutionMappings ' + 'with node_type example.TransactionSubsystem.') + + # It's invalid in nested template. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path0)) + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownOutputError, errormsg) + + # Subtemplate deploy standaolone is invalid. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path1)) + exception.ExceptionCollector.assertExceptionMessage( + exception.UnknownOutputError, errormsg) + + def test_system_with_missing_output_validation(self): + tpl_path0 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/" + "system_invalid_missing_output.yaml") + tpl_path1 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/" + "transactionsubsystem_invalid_missing_output.yaml") + errormsg = _('SubstitutionMappings with node_type ' + 'example.TransactionSubsystem is missing ' + 'required output definition of output "receiver_port".') + + # It's invalid in nested template. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path0)) + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredOutputError, errormsg) + + # Subtemplate deploy standaolone is invalid. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path1)) + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredOutputError, errormsg) -- cgit 1.2.3-korg