diff --git a/toscaparser/elements/tosca_type_validation.py b/toscaparser/elements/tosca_type_validation.py index 5f1409b3..fe5b4442 100644 --- a/toscaparser/elements/tosca_type_validation.py +++ b/toscaparser/elements/tosca_type_validation.py @@ -23,12 +23,13 @@ class TypeValidation(object): DATA_TYPES, ARTIFACT_TYPES, GROUP_TYPES, RELATIONSHIP_TYPES, CAPABILITY_TYPES, INTERFACE_TYPES, POLICY_TYPES, - TOPOLOGY_TEMPLATE) = \ + TOPOLOGY_TEMPLATE, METADATA) = \ ('tosca_definitions_version', 'description', 'imports', 'dsl_definitions', 'node_types', 'repositories', 'data_types', 'artifact_types', 'group_types', 'relationship_types', 'capability_types', - 'interface_types', 'policy_types', 'topology_template') + 'interface_types', 'policy_types', 'topology_template', + 'metadata') VALID_TEMPLATE_VERSIONS = ['tosca_simple_yaml_1_0'] exttools = ExtTools() VALID_TEMPLATE_VERSIONS.extend(exttools.get_versions()) diff --git a/toscaparser/tests/data/custom_types/template_metadata.yaml b/toscaparser/tests/data/custom_types/template_metadata.yaml new file mode 100644 index 00000000..c17defdb --- /dev/null +++ b/toscaparser/tests/data/custom_types/template_metadata.yaml @@ -0,0 +1,12 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +metadata: + template_name: name + template_version: 1.0.0 + template_author: me + +node_types: + + tosca.nodes.SomeNode: + derived_from: tosca.nodes.SoftwareComponent + diff --git a/toscaparser/tests/data/test_import_metadata.yml b/toscaparser/tests/data/test_import_metadata.yml new file mode 100644 index 00000000..acdbb431 --- /dev/null +++ b/toscaparser/tests/data/test_import_metadata.yml @@ -0,0 +1,13 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +imports: + - invalid: custom_types/template_metadata.yaml + +description: > + Test to import a template with metadata + +topology_template: + node_templates: + test: + type: tosca.nodes.SomeNode + diff --git a/toscaparser/tests/test_toscatplvalidation.py b/toscaparser/tests/test_toscatplvalidation.py index 28919daa..d5e6716f 100644 --- a/toscaparser/tests/test_toscatplvalidation.py +++ b/toscaparser/tests/test_toscatplvalidation.py @@ -1453,6 +1453,12 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml '{\'invalid\': \'custom_types/invalid_template_version.yaml\'}"' ' is invalid. Valid versions are "%s".') % valid_versions)) + def test_import_template_metadata(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_import_metadata.yml") + ToscaTemplate(tosca_tpl) + def test_node_template_capabilities_properties(self): # validating capability property values tpl_snippet = '''