Closes-Bug: #1746441
Fix error raising exception when importing a file with an invalid template version Change-Id: I31a0c1b477d8f8f234457021235f35c4bb9fee4d
This commit is contained in:
parent
784227cce4
commit
23cd991e88
|
@ -48,12 +48,12 @@ class TypeValidation(object):
|
|||
for name in custom_type:
|
||||
if name not in self.ALLOWED_TYPE_SECTIONS:
|
||||
ExceptionCollector.appendException(
|
||||
UnknownFieldError(what='Template ' + (self.import_def),
|
||||
UnknownFieldError(what='Template ' + str(self.import_def),
|
||||
field=name))
|
||||
|
||||
def _validate_type_version(self, version):
|
||||
if version not in self.VALID_TEMPLATE_VERSIONS:
|
||||
ExceptionCollector.appendException(
|
||||
InvalidTemplateVersion(
|
||||
what=version + ' in ' + self.import_def,
|
||||
what=version + ' in ' + str(self.import_def),
|
||||
valid_versions=', '. join(self.VALID_TEMPLATE_VERSIONS)))
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
tosca_definitions_version: tosca_simple_yaml_XXX
|
||||
|
||||
node_types:
|
||||
|
||||
tosca.nodes.SomeNode:
|
||||
derived_from: tosca.nodes.SoftwareComponent
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||
|
||||
imports:
|
||||
- invalid: custom_types/invalid_template_version.yaml
|
||||
|
||||
description: >
|
||||
Test to import a template with an invalid template version.
|
||||
|
||||
topology_template:
|
||||
node_templates:
|
||||
test:
|
||||
type: tosca.nodes.SomeNode
|
||||
|
|
@ -1441,6 +1441,18 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml
|
|||
(_('The template version "tosca_xyz" is invalid. Valid versions '
|
||||
'are "%s".') % valid_versions))
|
||||
|
||||
def test_import_invalid_template_version(self):
|
||||
tosca_tpl = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"data/test_import_invalid_template_version.yaml")
|
||||
self.assertRaises(exception.ValidationError, ToscaTemplate, tosca_tpl)
|
||||
valid_versions = ', '.join(ToscaTemplate.VALID_TEMPLATE_VERSIONS)
|
||||
exception.ExceptionCollector.assertExceptionMessage(
|
||||
exception.InvalidTemplateVersion,
|
||||
(_('The template version "tosca_simple_yaml_XXX in '
|
||||
'{\'invalid\': \'custom_types/invalid_template_version.yaml\'}"'
|
||||
' is invalid. Valid versions are "%s".') % valid_versions))
|
||||
|
||||
def test_node_template_capabilities_properties(self):
|
||||
# validating capability property values
|
||||
tpl_snippet = '''
|
||||
|
|
Loading…
Reference in New Issue