From 406214e5ca40ad57a1c40e4a8454336f6a26cac2 Mon Sep 17 00:00:00 2001 From: shangxdy Date: Sun, 26 Feb 2017 00:49:42 +0800 Subject: Sync upstream code Sync upstream project of tosca-parser Change-Id: Ic707844203ea05007b3c02e9dcadb52389eb3149 JIRA:PARSER-118 Signed-off-by: shangxdy --- .../toscaparser/tests/test_topology_template.py | 80 +++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) (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 0c26b67..3aabc9b 100644 --- a/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py +++ b/tosca2heat/tosca-parser/toscaparser/tests/test_topology_template.py @@ -220,48 +220,48 @@ class TopologyTemplateTest(TestCase): self.assertEqual(expected_message, err.__str__()) def test_invalid_nodetype(self): - tpl_snippet = ''' - substitution_mappings: - node_type: example.DatabaseSubsystem1 - capabilities: - database_endpoint: [ db_app, database_endpoint ] - requirements: - receiver1: [ tran_app, receiver1 ] - ''' - sub_mappings = (toscaparser.utils.yamlparser. - simple_parse(tpl_snippet))['substitution_mappings'] - custom_defs = self._get_custom_types() - expected_message = _('Node type "example.DatabaseSubsystem1" ' - 'is not a valid type.') - err = self.assertRaises( - exception.InvalidNodeTypeError, - lambda: SubstitutionMappings(sub_mappings, None, None, - None, None, custom_defs)) - self.assertEqual(expected_message, err.__str__()) + tpl_snippet = ''' + substitution_mappings: + node_type: example.DatabaseSubsystem1 + capabilities: + database_endpoint: [ db_app, database_endpoint ] + requirements: + receiver1: [ tran_app, receiver1 ] + ''' + sub_mappings = (toscaparser.utils.yamlparser. + simple_parse(tpl_snippet))['substitution_mappings'] + custom_defs = self._get_custom_types() + expected_message = _('Node type "example.DatabaseSubsystem1" ' + 'is not a valid type.') + err = self.assertRaises( + exception.InvalidNodeTypeError, + lambda: SubstitutionMappings(sub_mappings, None, None, + None, None, custom_defs)) + self.assertEqual(expected_message, err.__str__()) def test_system_with_input_validation(self): - tpl_path0 = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "data/topology_template/validate/system_invalid_input.yaml") - tpl_path1 = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "data/topology_template/validate/" - "queuingsubsystem_invalid_input.yaml") - errormsg = _('SubstitutionMappings with node_type ' - 'example.QueuingSubsystem is missing ' - 'required input definition of input "server_port".') - - # It's invalid in nested template. - self.assertRaises(exception.ValidationError, - lambda: ToscaTemplate(tpl_path0)) - exception.ExceptionCollector.assertExceptionMessage( - exception.MissingRequiredInputError, errormsg) - - # Subtemplate deploy standaolone is also invalid. - self.assertRaises(exception.ValidationError, - lambda: ToscaTemplate(tpl_path1)) - exception.ExceptionCollector.assertExceptionMessage( - exception.MissingRequiredInputError, errormsg) + tpl_path0 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/system_invalid_input.yaml") + tpl_path1 = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/topology_template/validate/" + "queuingsubsystem_invalid_input.yaml") + errormsg = _('SubstitutionMappings with node_type ' + 'example.QueuingSubsystem is missing ' + 'required input definition of input "server_port".') + + # It's invalid in nested template. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path0)) + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredInputError, errormsg) + + # Subtemplate deploy standaolone is also invalid. + self.assertRaises(exception.ValidationError, + lambda: ToscaTemplate(tpl_path1)) + exception.ExceptionCollector.assertExceptionMessage( + exception.MissingRequiredInputError, errormsg) def test_system_with_unknown_output_validation(self): tpl_path0 = os.path.join( -- cgit 1.2.3-korg