Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-1-parser-test-suite 72c52f86b -> 3037a3fa8 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py deleted file mode 100644 index cfb8c98..0000000 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import pytest - -from ... import data -from ......mechanisms.utils import matrix - - -# All fields except "requirements", which is a sequenced list -DICT_FIELD_NAMES = ('properties', 'attributes', 'capabilities', 'interfaces', 'artifacts') - - -# Fields - [email protected]('name,value', matrix( - DICT_FIELD_NAMES, - data.NOT_A_DICT -)) -def test_node_type_fields_syntax_type(parser, name, value): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: - {{ name }}: {{ value }} -""", dict(name=name, value=value)).assert_failure() - - [email protected]('name', DICT_FIELD_NAMES) -def test_node_type_fields_syntax_empty(parser, name): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: - {{ name }}: {} -""", dict(name=name)).assert_success() - - -def test_node_type_requirements_syntax_empty(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: - requirements: [] -""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_artifacts.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_artifacts.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_artifacts.py new file mode 100644 index 0000000..0c28d5a --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_artifacts.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from ... import data + + +# Artifacts section + [email protected]('value', data.NOT_A_DICT) +def test_node_type_artifacts_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_artifacts_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: {} +""").assert_success() + + +# Artifact + [email protected]('value', data.NOT_A_DICT) +def test_node_type_artifact_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: + my_artifact: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_artifact_syntax_unsupported(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +artifact_types: + MyType: {} +node_types: + MyType: + artifacts: + my_artifact: + type: MyType + unsupported: {} +""").assert_failure() + + +def test_node_type_artifact_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + artifacts: + my_artifact: {} # "type" is required +""").assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py index fba969a..1edc2cb 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py @@ -18,7 +18,29 @@ import pytest from ... import data -# Syntax + +# Capabilities section + [email protected]('value', data.NOT_A_DICT) +def test_node_type_capabilities_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_capabilities_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + capabilities: {} +""").assert_success() + + +# Capability @pytest.mark.parametrize('value', data.NOT_A_DICT) def test_node_type_capability_syntax_type(parser, value): @@ -153,23 +175,23 @@ node_types: # Valid source types -def test_node_type_capability_valid_source_types(parser): [email protected]('value', data.NOT_A_LIST) +def test_node_type_capability_valid_source_types_syntax_type(parser, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: MyType: {} node_types: - MyType1: + MyType: capabilities: my_capability: type: MyType - valid_source_types: [ MyType1, MyType2 ] - MyType2: {} -""").assert_success() + valid_source_types: {{ value }} +""", dict(value=value)).assert_failure() [email protected]('value', data.NOT_A_LIST) -def test_node_type_capability_valid_source_types_syntax_type(parser, value): [email protected]('value', data.NOT_A_STRING) +def test_node_type_capability_valid_source_types_syntax_element_type(parser, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: @@ -179,12 +201,11 @@ node_types: capabilities: my_capability: type: MyType - valid_source_types: {{ value }} + valid_source_types: [ {{ value }} ] """, dict(value=value)).assert_failure() [email protected]('value', data.NOT_A_STRING) -def test_node_type_capability_valid_source_types_syntax_element_type(parser, value): +def test_node_type_capability_valid_source_types_syntax_empty(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: @@ -194,21 +215,23 @@ node_types: capabilities: my_capability: type: MyType - valid_source_types: [ {{ value }} ] -""", dict(value=value)).assert_failure() + valid_source_types: [] +""").assert_success() + -def test_node_type_capability_valid_source_syntax_empty(parser): +def test_node_type_capability_valid_source_types(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: MyType: {} node_types: - MyType: + MyType1: capabilities: my_capability: type: MyType - valid_source_types: [] + valid_source_types: [ MyType1, MyType2 ] + MyType2: {} """).assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py index 0c29595..710bd22 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py @@ -19,7 +19,28 @@ import pytest from ... import data -# Syntax +# Requirements section + [email protected]('value', data.NOT_A_LIST) +def test_node_type_requirements_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + requirements: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_node_type_requirements_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: + requirements: [] +""").assert_success() + + +# Requirement @pytest.mark.parametrize('value', data.NOT_A_DICT) def test_node_type_requirement_syntax_type(parser, value): @@ -96,6 +117,8 @@ node_types: """).assert_success() +# Capability type + def test_node_type_requirement_capability_type_unknown(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -182,7 +205,7 @@ node_types: # Relationship @pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING) -def test_node_type_requirement_relationship_type_syntax_type(parser, value): +def test_node_type_requirement_relationship_syntax_type(parser, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: @@ -227,6 +250,24 @@ node_types: """).assert_success() +# Relationship type + [email protected]('value', data.NOT_A_DICT_OR_STRING) +def test_node_type_requirement_relationship_type_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType + relationship: + type: {{ value }} +""", dict(value=value)).assert_failure() + + def test_node_type_requirement_relationship_type_unknown(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py index 0459d11..ff579f9 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py @@ -19,18 +19,6 @@ import pytest from .. import data -# Syntax - -def test_artifact_type_fields(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -artifact_types: - MyType: - mime_type: a mime type - file_ext: [ an extension ] -""").assert_success() - - # MIME type @pytest.mark.parametrize('value', data.NOT_A_STRING) @@ -55,20 +43,20 @@ artifact_types: """, dict(value=value)).assert_failure() -def test_artifact_type_file_ext_syntax_empty(parser): [email protected]('value', data.NOT_A_STRING) +def test_artifact_type_file_ext_syntax_element_type(parser, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: - file_ext: [] -""").assert_success() + file_ext: [ {{ value }} ] +""", dict(value=value)).assert_failure() [email protected]('value', data.NOT_A_STRING) -def test_artifact_type_file_ext_syntax_element_type(parser, value): +def test_artifact_type_file_ext_syntax_empty(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: - file_ext: [ {{ value }} ] -""", dict(value=value)).assert_failure() + file_ext: [] +""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py index d296930..1bdd0a7 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py @@ -19,7 +19,7 @@ import pytest from .. import data -# Operations +# Operation def test_interface_type_operation_syntax_empty(parser): parser.parse_literal(""" @@ -105,7 +105,7 @@ interface_types: @pytest.mark.parametrize('value', data.NOT_A_STRING) -def test_interface_type_operation_dependencies_element_syntax_type(parser, value): +def test_interface_type_operation_dependencies_syntax_element_type(parser, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 interface_types: @@ -118,6 +118,18 @@ interface_types: """, dict(value=value)).assert_failure() +def test_interface_type_operation_dependencies_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: + my_operation: + implementation: + primary: an implementation + dependencies: [] +""").assert_success() + + # Unicode def test_interface_type_unicode(parser): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/mechanisms/parsing/__init__.py ---------------------------------------------------------------------- diff --git a/tests/mechanisms/parsing/__init__.py b/tests/mechanisms/parsing/__init__.py index b2b5146..1e6750a 100644 --- a/tests/mechanisms/parsing/__init__.py +++ b/tests/mechanisms/parsing/__init__.py @@ -51,13 +51,13 @@ class Parser(object): def __init__(self): self.verbose = False - def parse_literal(self, text, context=None): + def parse_literal(self, text, context=None, import_profile=False): text = render(text, context) - parsed = self._parse_literal(text) + parsed = self._parse_literal(text, import_profile) parsed.verbose = self.verbose return parsed - def _parse_literal(self, text): + def _parse_literal(self, text, import_profile): raise NotImplementedError def __enter__(self): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/mechanisms/parsing/aria.py ---------------------------------------------------------------------- diff --git a/tests/mechanisms/parsing/aria.py b/tests/mechanisms/parsing/aria.py index 63aadb7..c9b4630 100644 --- a/tests/mechanisms/parsing/aria.py +++ b/tests/mechanisms/parsing/aria.py @@ -29,8 +29,8 @@ from . import (Parser, Parsed) class AriaParser(Parser): - def _parse_literal(self, text): - context = AriaParser.create_context() + def _parse_literal(self, text, import_profile): + context = AriaParser.create_context(import_profile=import_profile) context.presentation.location = LiteralLocation(text) consumer = AriaParser.create_consumer(context) consumer.consume() @@ -45,13 +45,17 @@ class AriaParser(Parser): reader_source='aria.parser.reading.DefaultReaderSource', presenter_source='aria.parser.presentation.DefaultPresenterSource', presenter=None, - debug=False): + debug=False, + cache=True, + import_profile=True): context = ConsumptionContext() context.loading.loader_source = import_fullname(loader_source)() context.reading.reader_source = import_fullname(reader_source)() context.presentation.presenter_source = import_fullname(presenter_source)() context.presentation.presenter_class = import_fullname(presenter) context.presentation.threads = 1 # tests already run in maximum thread density + context.presentation.cache = cache + context.presentation.import_profile = import_profile context.presentation.print_exceptions = debug return context http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3037a3fa/tests/parser/service_templates.py ---------------------------------------------------------------------- diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py index 9e8fcae..9b3923f 100644 --- a/tests/parser/service_templates.py +++ b/tests/parser/service_templates.py @@ -69,7 +69,6 @@ def consume_node_cellar(consumer_class_name='instance', cache=True): consumer_class_name=consumer_class_name, inputs_uri=get_service_template_uri('tosca-simple-1.0', 'node-cellar', 'inputs.yaml'), cache=cache - )
