summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2016-12-08 11:42:45 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2016-12-09 23:40:43 +0800
commit7f2bbc7c5913a39d49fdc6533c708939b47a9233 (patch)
tree5736370b8f31ff725e5021fda3f36b4981e55347 /tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py
parentd098a14d69bf78b7674ec5d75003c21250e640bc (diff)
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 <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py49
1 files changed, 49 insertions, 0 deletions
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)