Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 673D0200D01 for ; Fri, 22 Sep 2017 21:36:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 65BFB1609D0; Fri, 22 Sep 2017 19:36:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 346241609BE for ; Fri, 22 Sep 2017 21:36:00 +0200 (CEST) Received: (qmail 73171 invoked by uid 500); 22 Sep 2017 19:35:59 -0000 Mailing-List: contact commits-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list commits@ariatosca.incubator.apache.org Received: (qmail 73160 invoked by uid 99); 22 Sep 2017 19:35:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Sep 2017 19:35:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D3FBC1A683B for ; Fri, 22 Sep 2017 19:35:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id nhNXpiAYIZkO for ; Fri, 22 Sep 2017 19:35:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 7FB9A5FBBA for ; Fri, 22 Sep 2017 19:35:54 +0000 (UTC) Received: (qmail 73013 invoked by uid 99); 22 Sep 2017 19:35:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Sep 2017 19:35:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AB5A2F3311; Fri, 22 Sep 2017 19:35:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: emblemparade@apache.org To: commits@ariatosca.incubator.apache.org Date: Fri, 22 Sep 2017 19:35:53 -0000 Message-Id: <63be24af29314f2396dfa9dc6914ae54@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-ariatosca git commit: Vast speed ups: [Forced Update!] archived-at: Fri, 22 Sep 2017 19:36:01 -0000 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 - -@pytest.mark.parametrize('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() - - -@pytest.mark.parametrize('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 + +@pytest.mark.parametrize('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 + +@pytest.mark.parametrize('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 + +@pytest.mark.parametrize('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): +@pytest.mark.parametrize('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() -@pytest.mark.parametrize('value', data.NOT_A_LIST) -def test_node_type_capability_valid_source_types_syntax_type(parser, value): +@pytest.mark.parametrize('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() -@pytest.mark.parametrize('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 + +@pytest.mark.parametrize('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 + +@pytest.mark.parametrize('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): +@pytest.mark.parametrize('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() -@pytest.mark.parametrize('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 - )