You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by em...@apache.org on 2017/08/30 22:13:17 UTC
[01/10] incubator-ariatosca git commit: ARIA-352 Fixed package name
aria[ssh] incorrect in the installation document link [Forced Update!]
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-1-parser-test-suite eb8cd553c -> 75225e881 (forced update)
ARIA-352 Fixed package name aria[ssh] incorrect in the installation document link
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/a5b450aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a5b450aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a5b450aa
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: a5b450aa66c816a6334c00be96d7f50cb6b248e6
Parents: 8981791
Author: Vishwanath Jayaraman <vi...@hotmail.com>
Authored: Mon Aug 21 13:50:55 2017 +0000
Committer: Vishwanath Jayaraman <vi...@hotmail.com>
Committed: Mon Aug 21 13:50:55 2017 +0000
----------------------------------------------------------------------
README.rst | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a5b450aa/README.rst
----------------------------------------------------------------------
diff --git a/README.rst b/README.rst
index b9a8213..b1a48c2 100644
--- a/README.rst
+++ b/README.rst
@@ -53,22 +53,22 @@ To install ARIA from source, download the source tarball from
**Ubuntu/Debian** (tested on Ubuntu14.04, Ubuntu16.04)::
apt-get install -y python-dev gcc libffi-dev libssl-dev
- pip install aria[ssh]
+ pip install apache-ariatosca[ssh]
**Centos** (tested on Centos6.6, Centos7)::
yum install -y python-devel gcc libffi-devel openssl-devel
- pip install aria[ssh]
+ pip install apache-ariatosca[ssh]
**Archlinux**::
pacman -Syu --noconfirm python2 gcc libffi openssl
- pip2 install aria[ssh]
+ pip2 install apache-ariatosca[ssh]
**Windows** (tested on Win10)::
# no additional system requirements are needed
- pip install aria[ssh]
+ pip install apache-ariatosca[ssh]
**MacOS**::
[04/10] incubator-ariatosca git commit: More tests,
some reorganization
Posted by em...@apache.org.
More tests, some reorganization
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8b7f6604
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8b7f6604
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8b7f6604
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 8b7f6604b444e2f46dcf0bf3bfe8756d4e0004c8
Parents: 8c05149
Author: Tal Liron <ta...@gmail.com>
Authored: Tue Aug 29 16:53:58 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500
----------------------------------------------------------------------
.../simple_v1_0/definitions.py | 2 +
.../simple_v1_0/test_imports.py | 2 +-
.../simple_v1_0/test_metadata.py | 4 +-
.../simple_v1_0/types/common/__init__.py | 14 +
.../types/common/test_type_interfaces.py | 413 +++++++++++++++++++
.../types/common/test_type_parameters.py | 334 +++++++++++++++
.../simple_v1_0/types/common/test_types.py | 152 +++++++
.../simple_v1_0/types/node_types/__init__.py | 14 +
.../types/node_types/test_node_type.py | 68 +++
.../node_types/test_node_type_capabilities.py | 222 ++++++++++
.../node_types/test_node_type_requirements.py | 36 ++
.../simple_v1_0/types/test_node_type.py | 68 ---
.../types/test_node_type_capabilities.py | 72 ----
.../types/test_node_type_requirements.py | 69 ----
.../simple_v1_0/types/test_type_interfaces.py | 410 ------------------
.../simple_v1_0/types/test_type_parameters.py | 334 ---------------
.../simple_v1_0/types/test_types.py | 152 -------
17 files changed, 1258 insertions(+), 1108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/extensions/aria_extension_tosca/simple_v1_0/definitions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/definitions.py b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
index da08a07..c1a2a66 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
@@ -342,6 +342,8 @@ class RelationshipDefinition(ExtensiblePresentation):
The optional reserved keyname used to provide the name of the Relationship Type for the
requirement definition's relationship keyname.
+ ARIA NOTE: the spec shows this as a required field.
+
:type: :obj:`basestring`
"""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
index 4d8af8b..0177ef7 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -138,7 +138,7 @@ topology_template:
""", dict(repository=repository)).assert_success()
-# Failures
+# Bad imports
def test_import_not_found(parser):
parser.parse_literal("""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
index 3f89bf6..1a109c1 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
@@ -59,7 +59,7 @@ metadata: {}
""").assert_success()
-# Normative
+# Normative fields
@pytest.mark.parametrize('value', data.GOOD_VERSIONS)
def test_metadata_normative_template_version(parser, value):
@@ -79,7 +79,7 @@ metadata:
""", dict(value=value)).assert_failure()
-# Non-normative
+# Non-normative fields
def test_metadata_with_non_normative_fields(parser):
parser.parse_literal("""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
new file mode 100644
index 0000000..185451e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
@@ -0,0 +1,413 @@
+# -*- 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 itertools
+
+import pytest
+
+from ... import data
+
+
+TYPE_NAMES = ('node', 'relationship', 'group')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_interface_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {} # "type" is required
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ operation1: {}
+ operation2: {}
+""", dict(name=name)).assert_success()
+
+
+# Type
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override_good(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2: {}
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2: {}
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_same(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_derived(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ description: a description
+ implementation: {}
+ inputs: {}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_short_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation: an implementation
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_long_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_same_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_derived_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: MyType1
+""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
new file mode 100644
index 0000000..291abc8
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
@@ -0,0 +1,334 @@
+# -*- 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 itertools
+
+import pytest
+
+from ... import data
+
+
+SECTIONS = (
+ ('artifact', 'properties'),
+ ('data', 'properties'),
+ ('capability', 'properties'),
+ ('capability', 'attributes'),
+ ('interface', 'inputs'),
+ ('relationship', 'properties'),
+ ('relationship', 'attributes'),
+ ('node', 'properties'),
+ ('node', 'attributes'),
+ ('group', 'properties'),
+ ('policy', 'properties')
+)
+SECTION_NAMES = ('properties', 'attributes')
+ENTRY_SCHEMA_VALUES = (
+ ('string', 'a string', 'another string'),
+ ('integer', '1', '2'),
+ ('float', '1.1', '2.2')
+)
+ENTRY_SCHEMA_VALUES_BAD = (
+ ('string', 'a string', '1'),
+ ('integer', '1', 'a string'),
+ ('float', '1.1', 'a string')
+)
+
+
+# Fields
+
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_fields(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Status
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(SECTIONS, data.STATUSES))
+)
+def test_node_type_parameter_status_good(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: {{ value }}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_status_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: not a status
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Entry schema
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_map(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_map_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_list(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_list_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+# Required
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_property_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_failure()
+
+
+def test_node_type_property_not_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ required: false
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+def test_node_type_property_required_with_default(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ default: a string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+# Overriding
+
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_parameter_add_default(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1:
+ {{ section }}:
+ my_parameter:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_parameter:
+ type: string
+ default: my value
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_parameter_type_override(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+node_types:
+ MyType1:
+ {{ section }}:
+ my_parameter:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_parameter:
+ type: MyType2
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_parameter_type_override_bad(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+node_types:
+ MyType1:
+ {{ section }}:
+ my_parameter:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_parameter:
+ type: MyType1
+""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
new file mode 100644
index 0000000..53845c5
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
@@ -0,0 +1,152 @@
+# -*- 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 itertools
+
+import pytest
+
+from ... import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Derivation
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: UnknownType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_null(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: null
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_self(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: MyType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_circular(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ derived_from: MyType3
+ MyType2:
+ derived_from: MyType1
+ MyType3:
+ derived_from: MyType2
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_root(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0
+ description: a description
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.BAD_VERSIONS
+))
+def test_type_bad_version(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/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
new file mode 100644
index 0000000..4b1c446
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py
@@ -0,0 +1,68 @@
+# -*- 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 itertools
+
+import pytest
+
+from ... import data
+
+# All fields except "requirements", which is a sequenced list
+DICT_FIELD_NAMES = ('properties', 'attributes', 'capabilities', 'interfaces', 'artifacts')
+
+
+# Fields
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ DICT_FIELD_NAMES,
+ data.NOT_A_DICT
+))
+def test_node_type_fields_wrong_yaml_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('value', data.NOT_A_LIST)
+def test_node_type_requirements_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', DICT_FIELD_NAMES)
+def test_node_type_fields_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_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/8b7f6604/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
new file mode 100644
index 0000000..0b1abf6
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
@@ -0,0 +1,222 @@
+# -*- 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
+
+
+SECTION_NAMES = ('properties', 'attributes')
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_capability_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability: {} # "type" is required
+""").assert_failure()
+
+
+def test_node_type_capability_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ description: a description
+ properties: {}
+ attributes: {}
+ valid_source_types: []
+ occurrences: [ 0, UNBOUNDED ]
+""").assert_success()
+
+
+# Type
+
+def test_node_type_capability_type_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: UnknownType
+""").assert_failure()
+
+
+def test_node_type_capability_type_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: null
+""").assert_failure()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_capability_type_override_good(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ capabilities:
+ my_capability:
+ type: MyType2
+""").assert_success()
+
+
+def test_node_type_capability_type_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ capabilities:
+ my_capability:
+ type: MyType1
+""").assert_failure()
+
+
+# Parameters
+
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_capability_parameter_add(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ section }}:
+ my_parameter2:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_capability_parameter_override(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+capability_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: MyType1
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ type: MyType2
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_capability_parameter_override_bad(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+capability_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: MyType2
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ type: MyType1
+""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/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
new file mode 100644
index 0000000..5ad866f
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
@@ -0,0 +1,36 @@
+# -*- 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.
+
+
+# Overriding
+
+def test_node_type_requirement_override_change_type_good(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1: {}
+ MyType2: {}
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType2 # you should be allowed to change the capability type to anything
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
deleted file mode 100644
index b2767c1..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
+++ /dev/null
@@ -1,68 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-DICT_FIELD_NAMES = ('properties', 'attributes', 'capabilities', 'interfaces', 'artifacts')
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- DICT_FIELD_NAMES,
- data.NOT_A_DICT
-))
-def test_node_type_fields_wrong_yaml_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('value', data.NOT_A_LIST)
-def test_node_type_requirements_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- requirements: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', DICT_FIELD_NAMES)
-def test_node_type_fields_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_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/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
deleted file mode 100644
index fa9af73..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
+++ /dev/null
@@ -1,72 +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
-
-
-# Overriding
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_capability_override_change_type_good(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType1:
- properties:
- prop1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- prop2:
- type: integer
-node_types:
- MyType1:
- capabilities:
- my_capability:
- type: MyType1
- MyType2:
- derived_from: MyType1
- capabilities:
- my_capability:
- type: MyType2
-""").assert_success()
-
-
-def test_node_type_capability_override_change_type_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType1:
- properties:
- prop1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- prop2:
- type: integer
-node_types:
- MyType1:
- capabilities:
- my_capability:
- type: MyType2
- MyType2:
- derived_from: MyType1
- capabilities:
- my_capability:
- type: MyType1
-""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
deleted file mode 100644
index b823cd4..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
+++ /dev/null
@@ -1,69 +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.
-
-
-# Overriding
-
-def test_node_type_requirement_override_change_type_good1(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType1:
- properties:
- prop1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- prop2:
- type: integer
-node_types:
- MyType1:
- requirements:
- - my_requirement:
- capability: MyType1
- MyType2:
- derived_from: MyType1
- requirements:
- - my_requirement:
- capability: MyType2
-""").assert_success()
-
-
-def test_node_type_requirement_override_change_type_good2(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType1:
- properties:
- prop1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- prop2:
- type: integer
-node_types:
- MyType1:
- requirements:
- - my_requirement:
- capability: MyType2
- MyType2:
- derived_from: MyType1
- requirements:
- - my_requirement:
- capability: MyType1 # you should be allowed to change the capability type to anything
-""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
deleted file mode 100644
index 4b47a0b..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
+++ /dev/null
@@ -1,410 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-TYPE_NAMES = ('node', 'relationship', 'group')
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_interface_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {} # "type" is required
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs: {}
- operation1: {}
- operation2: {}
-""", dict(name=name)).assert_success()
-
-
-# Type
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_override_type_good(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2: {}
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType1
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_override_type_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2: {}
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType2
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Interface inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input2:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_override_same_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_override_derived_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Operations
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- description: a description
- implementation: {}
- inputs: {}
-""", dict(name=name)).assert_success()
-
-
-# Operation implementation
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_short_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation: an implementation
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_long_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: an implementation
- dependencies:
- - a dependency
- - another dependency
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: an implementation
- dependencies:
- - {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Operation inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input2:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_same_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_derived_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: MyType1
-""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
deleted file mode 100644
index 5f285ea..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
+++ /dev/null
@@ -1,334 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-SECTIONS = (
- ('artifact', 'properties'),
- ('data', 'properties'),
- ('capability', 'properties'),
- ('capability', 'attributes'),
- ('interface', 'inputs'),
- ('relationship', 'properties'),
- ('relationship', 'attributes'),
- ('node', 'properties'),
- ('node', 'attributes'),
- ('group', 'properties'),
- ('policy', 'properties')
-)
-SECTION_NAMES = ('properties', 'attributes')
-ENTRY_SCHEMA_VALUES = (
- ('string', 'a string', 'another string'),
- ('integer', '1', '2'),
- ('float', '1.1', '2.2')
-)
-ENTRY_SCHEMA_VALUES_BAD = (
- ('string', 'a string', '1'),
- ('integer', '1', 'a string'),
- ('float', '1.1', 'a string')
-)
-
-
-# Fields
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_fields(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_param:
- type: string
- description: a description
- default: a value
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- 參數:
- type: string
- description: 描述
- default: 值
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-# Status
-
-@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(SECTIONS, data.STATUSES))
-)
-def test_node_type_parameter_status_good(parser, name, parameter_section, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_param:
- type: string
- status: {{ value }}
-""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_status_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_param:
- type: string
- status: not a status
-""", dict(name=name, parameter_section=parameter_section)).assert_failure()
-
-
-# Entry schema
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_map(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_param:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_param:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_map_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_param:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_param:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_list(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_param:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_param:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_list_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_param:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_param:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-# Required
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_property_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_failure()
-
-
-def test_node_type_property_not_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- required: false
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-def test_node_type_property_required_with_default(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- default: a string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-# Overriding
-
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_override_add_default(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType1:
- {{ section }}:
- my_param:
- type: string
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_param:
- type: string
- default: my value
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('section', ('properties', 'attributes'))
-def test_node_type_parameter_override_change_type_good(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_param:
- type: MyType1
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_param:
- type: MyType2
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.parametrize('section', ('properties', 'attributes'))
-def test_node_type_parameter_override_change_type_bad(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_param:
- type: MyType2
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_param:
- type: MyType1
-""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b7f6604/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
deleted file mode 100644
index 8e2f26f..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
+++ /dev/null
@@ -1,152 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_derived_from_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Derivation
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_unknown(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: UnknownType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_null(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: null
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_self(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: MyType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_circular(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- derived_from: MyType3
- MyType2:
- derived_from: MyType1
- MyType3:
- derived_from: MyType2
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_root(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0
- description: a description
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0.詠嘆調-10
- description: 描述
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.BAD_VERSIONS
-))
-def test_type_bad_version(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- version: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
[06/10] incubator-ariatosca git commit: Fix examples,
more tests for interfaces and parameters
Posted by em...@apache.org.
Fix examples, more tests for interfaces and parameters
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8c05149f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8c05149f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8c05149f
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 8c05149f1c6bfa69f73000d95f762331cd3f1887
Parents: deb02b2
Author: Tal Liron <ta...@gmail.com>
Authored: Mon Aug 28 16:14:37 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500
----------------------------------------------------------------------
.travis.yml | 2 +
.../use-cases/non-normative-types.yaml | 1 +
.../types/test_node_type_interfaces.py | 72 ----
.../simple_v1_0/types/test_type_interfaces.py | 410 +++++++++++++++++++
.../simple_v1_0/types/test_type_parameters.py | 18 +-
5 files changed, 430 insertions(+), 73 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index c423114..4aafd5b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,8 @@
sudo: false
+# TODO: The default dist is "trusty", but it is broken for us because it doesn't have Python 2.6,
+# and does not allow SSH access (for py2?ssh tests)
dist: precise
language: python
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
----------------------------------------------------------------------
diff --git a/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml b/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
index 24f22a3..6e63ca1 100644
--- a/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
+++ b/examples/tosca-simple-1.0/use-cases/non-normative-types.yaml
@@ -161,6 +161,7 @@ node_types:
default: https://github.com/mmm/testnode.git
interfaces:
Standard:
+ type: tosca.interfaces.node.lifecycle.Standard # ARIA NOTE: missing in spec
inputs:
github_url:
type: string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
deleted file mode 100644
index 0228c02..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
+++ /dev/null
@@ -1,72 +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
-
-
-# Overriding
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_interface_override_change_type_good(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- inputs:
- input1:
- type: string
- MyType2:
- derived_from: MyType1
- inputs:
- input2:
- type: integer
-node_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType1
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType2
-""").assert_success()
-
-
-def test_node_type_interface_override_change_type_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- inputs:
- input1:
- type: string
- MyType2:
- derived_from: MyType1
- inputs:
- input2:
- type: integer
-node_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType2
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType1
-""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
new file mode 100644
index 0000000..4b47a0b
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
@@ -0,0 +1,410 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+TYPE_NAMES = ('node', 'relationship', 'group')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_interface_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {} # "type" is required
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ operation1: {}
+ operation2: {}
+""", dict(name=name)).assert_success()
+
+
+# Type
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_override_type_good(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2: {}
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_override_type_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2: {}
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_same_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_derived_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input1:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ description: a description
+ implementation: {}
+ inputs: {}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_short_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation: an implementation
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_long_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_same_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_derived_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ operation1:
+ inputs:
+ my_input1:
+ type: MyType1
+""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8c05149f/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
index be5ad43..5f285ea 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
@@ -26,6 +26,7 @@ SECTIONS = (
('data', 'properties'),
('capability', 'properties'),
('capability', 'attributes'),
+ ('interface', 'inputs'),
('relationship', 'properties'),
('relationship', 'attributes'),
('node', 'properties'),
@@ -63,6 +64,21 @@ tosca_definitions_version: tosca_simple_yaml_1_0
""", dict(name=name, parameter_section=parameter_section)).assert_success()
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
# Status
@pytest.mark.parametrize(
@@ -91,7 +107,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
{{ parameter_section }}:
my_param:
type: string
- status: bad
+ status: not a status
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
[03/10] incubator-ariatosca git commit: ARIA-353 Add node template
directives
Posted by em...@apache.org.
ARIA-353 Add node template directives
The directives field already existed in the presentation level, but it
needed to be added to the node template model.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/969149bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/969149bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/969149bd
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 969149bd98a9f2b60b98b2d0f1e64392d7c9f2da
Parents: a048f70
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed Aug 30 17:54:46 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Wed Aug 30 17:58:16 2017 +0300
----------------------------------------------------------------------
aria/modeling/service_template.py | 6 ++++++
aria/parser/presentation/fields.py | 5 +++--
.../aria_extension_tosca/simple_v1_0/modeling/__init__.py | 6 ++++--
3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index d988d21..cd0adb4 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -457,6 +457,12 @@ class NodeTemplateBase(TemplateModelMixin):
:type: :obj:`basestring`
""")
+ directives = Column(PickleType, doc="""
+ Directives that apply to this node template.
+
+ :type: [:obj:`basestring`]
+ """)
+
default_instances = Column(Integer, default=1, doc="""
Default number nodes that will appear in the service.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/aria/parser/presentation/fields.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/fields.py b/aria/parser/presentation/fields.py
index 5c08d4a..5c3e074 100644
--- a/aria/parser/presentation/fields.py
+++ b/aria/parser/presentation/fields.py
@@ -437,7 +437,7 @@ class Field(object):
raw = deepcopy_with_locators(default_raw)
merge(raw, presentation._raw)
- # Handle unknown fields
+ # Handle unknown fields (only dict can have unknown fields, lists can't have them)
if self.field_variant == 'primitive_dict_unknown_fields':
return self._get_primitive_dict_unknown_fields(presentation, raw, context)
@@ -473,7 +473,8 @@ class Field(object):
# Handle get according to variant
- getter = getattr(self, '_get_%s' % self.field_variant, None)
+ getter = getattr(self, '_get_{field_variant}'.format(field_variant=self.field_variant),
+ None)
if getter is None:
locator = self.get_locator(raw)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/969149bd/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index 1f90d29..d960e05 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -163,12 +163,14 @@ def create_metadata_models(context, service_template, metadata):
def create_node_template_model(context, service_template, node_template):
node_type = node_template._get_type(context)
node_type = service_template.node_types.get_descendant(node_type._name)
- model = NodeTemplate(name=node_template._name,
- type=node_type)
+ model = NodeTemplate(name=node_template._name, type=node_type)
if node_template.description:
model.description = node_template.description.value
+ if node_template.directives:
+ model.directives = node_template.directives
+
model.properties.update(create_property_models_from_values(
template_properties=node_template._get_property_values(context)))
model.attributes.update(create_attribute_models_from_values(
[09/10] incubator-ariatosca git commit: Most type tests complete
Posted by em...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py
new file mode 100644
index 0000000..97bf101
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py
@@ -0,0 +1,121 @@
+# -*- 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
+
+
+# Targets
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_policy_type_targets_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+ MyType:
+ targets: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_policy_type_targets_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+ MyType:
+ targets: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_policy_type_targets_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+ MyType:
+ targets: []
+""").assert_success()
+
+
+def test_policy_type_targets_nodes(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+ MyType2: {}
+policy_types:
+ MyType:
+ targets: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_policy_type_targets_groups(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType1: {}
+ MyType2: {}
+policy_types:
+ MyType:
+ targets: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_policy_type_targets_nodes_and_groups(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+group_types:
+ MyType2: {}
+policy_types:
+ MyType:
+ targets: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_policy_type_targets_ambiguous(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType: {}
+group_types:
+ MyType: {}
+policy_types:
+ MyType:
+ targets: [ MyType ]
+""").assert_success()
+
+
+def test_policy_type_targets_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+policy_types:
+ 類型:
+ targets: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_policy_type_targets_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+ MyType:
+ targets: [ UnknownType ]
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py
new file mode 100644
index 0000000..b0d8ab0
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py
@@ -0,0 +1,83 @@
+# -*- 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
+
+
+# Valid target types
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_relationship_type_valid_target_types_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+relationship_types:
+ MyType:
+ valid_target_types: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_relationship_type_valid_target_types_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+relationship_types:
+ MyType:
+ valid_target_types: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_relationship_type_valid_target_types_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+relationship_types:
+ MyType:
+ valid_target_types: []
+""").assert_success()
+
+
+def test_relationship_type_valid_target_types(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1: {}
+ MyType2: {}
+relationship_types:
+ MyType:
+ valid_target_types: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_relationship_type_valid_target_types_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型一: {}
+ 類型二: {}
+relationship_types:
+ 類型:
+ valid_target_types: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_relationship_type_valid_target_types_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+relationship_types:
+ MyType:
+ valid_target_types: [ UnknownType ]
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
new file mode 100644
index 0000000..c4283bd
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
@@ -0,0 +1,438 @@
+# -*- 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.
+
+
+"""
+Developer note: make sure that these tests mirror those in
+test_node_type_relationship_interfaces.py.
+"""
+
+import itertools
+
+import pytest
+
+from .. import data
+
+
+TYPE_NAMES = ('node', 'relationship', 'group')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_interface_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {} # "type" is required
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ my_operation1: {}
+ my_operation2: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ 類型: {}
+{{ name }}_types:
+ 類型:
+ interfaces:
+ 接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+""", dict(name=name)).assert_success()
+
+
+# Type
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_same(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_derived(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ description: a description
+ implementation: {}
+ inputs: {}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_short_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_long_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_same_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_derived_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
new file mode 100644
index 0000000..bb65bbd
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
@@ -0,0 +1,165 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+# Fields
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_fields(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Status
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(data.PARAMETER_SECTIONS, data.STATUSES))
+)
+def test_node_type_parameter_status(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: {{ value }}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_status_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: not a status
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Overriding
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_add(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter2:
+ type: string
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_add_default(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ default: my value
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_type_override(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType2
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_node_type_parameter_type_override_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType1
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
new file mode 100644
index 0000000..8e2f26f
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
@@ -0,0 +1,152 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Derivation
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: UnknownType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_null(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: null
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_self(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: MyType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_circular(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ derived_from: MyType3
+ MyType2:
+ derived_from: MyType1
+ MyType3:
+ derived_from: MyType2
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_root(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0
+ description: a description
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.BAD_VERSIONS
+))
+def test_type_bad_version(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
[02/10] incubator-ariatosca git commit: ARIA-348 Validate
substitution_mapping field
Posted by em...@apache.org.
ARIA-348 Validate substitution_mapping field
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/a048f704
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a048f704
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a048f704
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: a048f70491ff0dfa3a6f0d41be6d1294e2ee7061
Parents: a5b450a
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed Aug 16 18:54:57 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Aug 24 11:30:48 2017 +0300
----------------------------------------------------------------------
.travis.yml | 1 +
.../aria_extension_tosca/simple_v1_0/misc.py | 8 +-
.../modeling/substitution_mappings.py | 175 +++++++++++--------
.../aria_extension_tosca/simple_v1_0/types.py | 9 +-
4 files changed, 116 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a048f704/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index c8b7645..a7362e7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@ sudo: false
language: python
+dist: precise
python:
- '2.7'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a048f704/extensions/aria_extension_tosca/simple_v1_0/misc.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/misc.py b/extensions/aria_extension_tosca/simple_v1_0/misc.py
index a65ff41..221163c 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -25,8 +25,8 @@ from aria.parser.presentation import (AsIsPresentation, has_fields, allow_unknow
from .modeling.data_types import (get_data_type, get_data_type_value, get_property_constraints,
apply_constraint_to_value)
-from .modeling.substitution_mappings import (validate_subtitution_mappings_requirement,
- validate_subtitution_mappings_capability)
+from .modeling.substitution_mappings import (validate_substitution_mappings_requirement,
+ validate_substitution_mappings_capability)
from .presentation.extensible import ExtensiblePresentation
from .presentation.field_validators import (constraint_clause_field_validator,
constraint_clause_in_range_validator,
@@ -380,7 +380,7 @@ class SubstitutionMappingsRequirement(AsIsPresentation):
def _validate(self, context):
super(SubstitutionMappingsRequirement, self)._validate(context)
- validate_subtitution_mappings_requirement(context, self)
+ validate_substitution_mappings_requirement(context, self)
class SubstitutionMappingsCapability(AsIsPresentation):
@@ -400,7 +400,7 @@ class SubstitutionMappingsCapability(AsIsPresentation):
def _validate(self, context):
super(SubstitutionMappingsCapability, self)._validate(context)
- validate_subtitution_mappings_capability(context, self)
+ validate_substitution_mappings_capability(context, self)
@has_fields
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a048f704/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
index 8f7ec4c..e2af4b8 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
@@ -17,88 +17,113 @@ from aria.utils.formatting import safe_repr
from aria.parser.validation import Issue
-def validate_subtitution_mappings_requirement(context, presentation):
- if not validate_format(context, presentation, 'requirement'):
- return
+def validate_substitution_mappings_requirement(context, presentation):
- node_template = get_node_template(context, presentation, 'requirement')
- if node_template is None:
+ # validate that the requirement in substitution_mapping is defined in the substitution node type
+ substitution_node_type = presentation._container._get_type(context)
+ if substitution_node_type is None:
+ return
+ for req_name, req in substitution_node_type._get_requirements(context):
+ if req_name == presentation._name:
+ substitution_type_requirement = req
+ break
+ else:
+ context.validation.report(
+ 'substitution mapping requirement "{0}" is not declared in node type "{1}"'.format(
+ presentation._name, substitution_node_type._name),
+ locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return
- node_type = presentation._container._get_type(context)
- if node_type is None:
+ if not _validate_mapping_format(presentation):
+ _report_invalid_mapping_format(context, presentation, field='requirement')
return
- requirements = node_type._get_requirements(context)
- type_requirement = None
- for name, the_requirement in requirements:
- if name == presentation._name:
- type_requirement = the_requirement
+ # validate that the mapped requirement is defined in the corresponding node template
+ node_template = _get_node_template(context, presentation)
+ if node_template is None:
+ _report_missing_node_template(context, presentation, field='requirement')
+ return
+ mapped_requirement_name = presentation._raw[1]
+ for req_name, req in node_template._get_requirements(context):
+ if req_name == mapped_requirement_name:
+ node_template_requirement = req
break
- if type_requirement is None:
+ else:
context.validation.report(
- 'substitution mappings requirement "%s" is not declared in node type "%s"'
- % (presentation._name, node_type._name),
+ 'substitution mapping requirement "{0}" refers to an unknown requirement of node '
+ 'template "{1}": {mapped_requirement_name}'.format(
+ presentation._name, node_template._name,
+ mapped_requirement_name=safe_repr(mapped_requirement_name)),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return
- requirement_name = presentation._raw[1]
- requirements = node_template._get_requirements(context)
- requirement = None
- for name, the_requirement in requirements:
- if name == requirement_name:
- requirement = the_requirement
- break
-
- if requirement is None:
+ # validate that the requirement's capability type in substitution_mapping is derived from the
+ # requirement's capability type in the corresponding node template
+ substitution_type_requirement_capability_type = \
+ substitution_type_requirement._get_capability_type(context)
+ node_template_requirement_capability_type = \
+ node_template_requirement._get_capability(context)[0]
+ if not node_template_requirement_capability_type._is_descendant(
+ context, substitution_type_requirement_capability_type):
context.validation.report(
- 'substitution mappings requirement "%s" refers to an unknown requirement of node '
- 'template "%s": %s'
- % (presentation._name, node_template._name, safe_repr(requirement_name)),
+ 'substitution mapping requirement "{0}" of capability type "{1}" is not a descendant '
+ 'of the mapped node template capability type "{2}"'.format(
+ presentation._name,
+ substitution_type_requirement_capability_type._name,
+ node_template_requirement_capability_type._name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
- return
-def validate_subtitution_mappings_capability(context, presentation):
- if not validate_format(context, presentation, 'capability'):
- return
+def validate_substitution_mappings_capability(context, presentation):
- node_template = get_node_template(context, presentation, 'capability')
- if node_template is None:
+ # validate that the capability in substitution_mapping is defined in the substitution node type
+ substitution_node_type = presentation._container._get_type(context)
+ if substitution_node_type is None:
return
-
- node_type = presentation._container._get_type(context)
- if node_type is None:
+ substitution_type_capabilities = substitution_node_type._get_capabilities(context)
+ substitution_type_capability = substitution_type_capabilities.get(presentation._name)
+ if substitution_type_capability is None:
+ context.validation.report(
+ 'substitution mapping capability "{0}" '
+ 'is not declared in node type "{substitution_type}"'.format(
+ presentation._name, substitution_type=substitution_node_type._name),
+ locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return
- capabilities = node_type._get_capabilities(context)
- type_capability = capabilities.get(presentation._name)
- if type_capability is None:
- context.validation.report(
- 'substitution mappings capability "%s" is not declared in node type "%s"'
- % (presentation._name, node_type._name), locator=presentation._locator,
- level=Issue.BETWEEN_TYPES)
+ if not _validate_mapping_format(presentation):
+ _report_invalid_mapping_format(context, presentation, field='capability')
return
- capability_name = presentation._raw[1]
- capabilities = node_template._get_capabilities(context)
- capability = capabilities.get(capability_name)
+ # validate that the capability in substitution_mapping is declared in the corresponding
+ # node template
+ node_template = _get_node_template(context, presentation)
+ if node_template is None:
+ _report_missing_node_template(context, presentation, field='capability')
+ return
+ mapped_capability_name = presentation._raw[1]
+ node_template_capability = node_template._get_capabilities(context).get(mapped_capability_name)
- if capability is None:
+ if node_template_capability is None:
context.validation.report(
- 'substitution mappings capability "%s" refers to an unknown capability of node template'
- ' "%s": %s'
- % (presentation._name, node_template._name, safe_repr(capability_name)),
+ 'substitution mapping capability "{0}" refers to an unknown '
+ 'capability of node template "{1}": {mapped_capability_name}'.format(
+ presentation._name, node_template._name,
+ mapped_capability_name=safe_repr(mapped_capability_name)),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
return
- type_capability_type = type_capability._get_type(context)
- capability_type = capability._get_type(context)
+ # validate that the capability type in substitution_mapping is derived from the capability type
+ # in the corresponding node template
+ substitution_type_capability_type = substitution_type_capability._get_type(context)
+ node_template_capability_type = node_template_capability._get_type(context)
- if not type_capability_type._is_descendant(context, capability_type):
+ if not substitution_type_capability_type._is_descendant(context, node_template_capability_type):
context.validation.report(
- 'type "%s" of substitution mappings capability "%s" is not a descendant of "%s"'
- % (capability_type._name, presentation._name, type_capability_type._name),
+ 'node template capability type "{0}" is not a descendant of substitution mapping '
+ 'capability "{1}" of type "{2}"'.format(
+ node_template_capability_type._name,
+ presentation._name,
+ substitution_type_capability_type._name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
@@ -106,25 +131,37 @@ def validate_subtitution_mappings_capability(context, presentation):
# Utils
#
-def validate_format(context, presentation, name):
- if (not isinstance(presentation._raw, list)) or (len(presentation._raw) != 2) \
- or (not isinstance(presentation._raw[0], basestring)) \
- or (not isinstance(presentation._raw[1], basestring)):
- context.validation.report(
- 'substitution mappings %s "%s" is not a list of 2 strings: %s'
- % (name, presentation._name, safe_repr(presentation._raw)),
- locator=presentation._locator, level=Issue.FIELD)
+def _validate_mapping_format(presentation):
+ """Validate that the mapping is a list of 2 strings"""
+ if not isinstance(presentation._raw, list) or \
+ len(presentation._raw) != 2 or \
+ not isinstance(presentation._raw[0], basestring) or \
+ not isinstance(presentation._raw[1], basestring):
return False
return True
-def get_node_template(context, presentation, name):
+def _get_node_template(context, presentation):
node_template_name = presentation._raw[0]
node_template = context.presentation.get_from_dict('service_template', 'topology_template',
'node_templates', node_template_name)
- if node_template is None:
- context.validation.report(
- 'substitution mappings %s "%s" refers to an unknown node template: %s'
- % (name, presentation._name, safe_repr(node_template_name)),
- locator=presentation._locator, level=Issue.FIELD)
return node_template
+
+
+def _report_missing_node_template(context, presentation, field):
+ context.validation.report(
+ 'substitution mappings {field} "{node_template_mapping}" '
+ 'refers to an unknown node template: {node_template_name}'.format(
+ field=field,
+ node_template_mapping=presentation._name,
+ node_template_name=safe_repr(presentation._raw[0])),
+ locator=presentation._locator, level=Issue.FIELD)
+
+
+def _report_invalid_mapping_format(context, presentation, field):
+ context.validation.report(
+ 'substitution mapping {field} "{field_name}" is not a list of 2 strings: {value}'.format(
+ field=field,
+ field_name=presentation._name,
+ value=safe_repr(presentation._raw)),
+ locator=presentation._locator, level=Issue.FIELD)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a048f704/extensions/aria_extension_tosca/simple_v1_0/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py
index 787aac2..0241917 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -300,12 +300,13 @@ class CapabilityType(ExtensiblePresentation):
'capability_types')
@cachedmethod
- def _is_descendant(self, context, the_type):
- if the_type is None:
+ def _is_descendant(self, context, other_type):
+ """returns True iff `other_type` is a descendant of the represented capability type"""
+ if other_type is None:
return False
- elif the_type._name == self._name:
+ elif other_type._name == self._name:
return True
- return self._is_descendant(context, the_type._get_parent(context))
+ return self._is_descendant(context, other_type._get_parent(context))
@cachedmethod
def _get_properties(self, context):
[07/10] incubator-ariatosca git commit: Testing types and templates
Posted by em...@apache.org.
Testing types and templates
* Fix "version" fields in types
* Improve version testing
* Add BlockingExecutor for better single-threaded performance
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9d1183ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9d1183ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9d1183ac
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 9d1183ac40311884c2384c91fa3b01166171ce17
Parents: 36e0aa5
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Aug 18 15:52:31 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500
----------------------------------------------------------------------
.travis.yml | 4 +
aria/parser/consumption/presentation.py | 15 +-
aria/parser/presentation/fields.py | 2 +-
aria/utils/threading.py | 151 ++++++++++++------
aria/utils/versions.py | 2 +-
.../simple_v1_0/presentation/field_getters.py | 20 +--
.../aria_extension_tosca/simple_v1_0/types.py | 23 ++-
.../simple_v1_0/conftest.py | 23 ++-
.../aria_extension_tosca/simple_v1_0/data.py | 40 +++++
.../simple_v1_0/test_imports.py | 18 ++-
.../simple_v1_0/test_metadata.py | 58 ++++---
.../simple_v1_0/test_templates.py | 129 ++++++++++++++++
.../simple_v1_0/test_types.py | 153 +++++++++++++++++++
tests/mechanisms/parsing/__init__.py | 28 +++-
tests/mechanisms/parsing/aria.py | 3 +-
tests/mechanisms/web_server.py | 11 +-
tests/parser/utils.py | 1 +
tests/requirements.txt | 6 +-
.../node-cellar/node-cellar.yaml | 2 +-
tests/utils/test_versions.py | 8 +-
tox.ini | 39 +++--
21 files changed, 599 insertions(+), 137 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index a7362e7..c423114 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,8 @@
sudo: false
+dist: precise
+
language: python
dist: precise
@@ -25,6 +27,8 @@ env:
- TOX_ENV=py26
- TOX_ENV=py27e2e
- TOX_ENV=py26e2e
+ - TOX_ENV=py27extensions
+ - TOX_ENV=py26extensions
- TOX_ENV=py27ssh
- TOX_ENV=py26ssh
- TOX_ENV=docs
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/aria/parser/consumption/presentation.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/presentation.py b/aria/parser/consumption/presentation.py
index 542b3f0..6d34ee1 100644
--- a/aria/parser/consumption/presentation.py
+++ b/aria/parser/consumption/presentation.py
@@ -14,8 +14,8 @@
# limitations under the License.
-from ...utils.threading import FixedThreadPoolExecutor
-from ...utils.formatting import json_dumps, yaml_dumps
+from ...utils.threading import (BlockingExecutor, FixedThreadPoolExecutor)
+from ...utils.formatting import (json_dumps, yaml_dumps)
from ..loading import UriLocation
from ..reading import AlreadyReadException
from ..presentation import PresenterNotFoundError
@@ -47,9 +47,14 @@ class Read(Consumer):
presenter = None
imported_presentations = None
- executor = FixedThreadPoolExecutor(size=self.context.presentation.threads,
- timeout=self.context.presentation.timeout)
- executor.print_exceptions = self.context.presentation.print_exceptions
+ if self.context.presentation.threads == 1:
+ executor = BlockingExecutor(print_exceptions=self.context.presentation.print_exceptions)
+ else:
+ executor = FixedThreadPoolExecutor(size=self.context.presentation.threads,
+ timeout=self.context.presentation.timeout,
+ print_exceptions=self.context.presentation \
+ .print_exceptions)
+
try:
presenter = self._present(self.context.presentation.location, None, None, executor)
executor.drain()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/aria/parser/presentation/fields.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/fields.py b/aria/parser/presentation/fields.py
index 5c3e074..c4b0c13 100644
--- a/aria/parser/presentation/fields.py
+++ b/aria/parser/presentation/fields.py
@@ -734,7 +734,7 @@ class Field(object):
primitive_dict[k] = self._coerce_primitive(v, context)
except ValueError as e:
raise InvalidValueError('%s is not a dict of "%s" values:'
- ' entry "%d" is %s'
+ ' entry "%s" is %s'
% (self.full_name, self.full_cls_name,
k, safe_repr(v)),
locator=self.get_locator(raw),
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/aria/utils/threading.py
----------------------------------------------------------------------
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index f5ca302..1a7b191 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -59,10 +59,9 @@ class DaemonThread(Thread):
pass
-# https://gist.github.com/tliron/81dd915166b0bfc64be08b4f8e22c835
-class FixedThreadPoolExecutor(object):
+class Executor(object):
"""
- Executes tasks in a fixed thread pool.
+ Executes tasks.
Makes sure to gather all returned results and thrown exceptions in one place, in order of task
submission.
@@ -93,7 +92,104 @@ class FixedThreadPoolExecutor(object):
print executor.returns
"""
- _CYANIDE = object() # Special task marker used to kill worker threads.
+ def __init__(self, print_exceptions=False):
+ self.print_exceptions = print_exceptions
+
+ def submit(self, func, *args, **kwargs):
+ """
+ Submit a task for execution.
+
+ The task will be called ASAP on the next available worker thread in the pool.
+
+ :raises ExecutorException: if cannot be submitted
+ """
+ raise NotImplementedError
+
+ def close(self):
+ """
+ Blocks until all current tasks finish execution and all worker threads are dead.
+
+ You cannot submit tasks anymore after calling this.
+
+ This is called automatically upon exit if you are using the ``with`` keyword.
+ """
+ pass
+
+ def drain(self):
+ """
+ Blocks until all current tasks finish execution, but leaves the worker threads alive.
+ """
+ pass
+
+ @property
+ def returns(self):
+ """
+ The returned values from all tasks, in order of submission.
+ """
+ return ()
+
+ @property
+ def exceptions(self):
+ """
+ The raised exceptions from all tasks, in order of submission.
+ """
+ return ()
+
+ def raise_first(self):
+ """
+ If exceptions were thrown by any task, then the first one will be raised.
+
+ This is rather arbitrary: proper handling would involve iterating all the exceptions.
+ However, if you want to use the "raise" mechanism, you are limited to raising only one of
+ them.
+ """
+
+ exceptions = self.exceptions
+ if exceptions:
+ raise exceptions[0]
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, the_type, value, traceback):
+ pass
+
+
+class BlockingExecutor(Executor):
+ """
+ Executes tasks in the current thread.
+ """
+
+ def __init__(self, print_exceptions=False):
+ super(BlockingExecutor, self).__init__(print_exceptions=print_exceptions)
+ self._returns = []
+ self._exceptions = []
+
+ def submit(self, func, *args, **kwargs):
+ try:
+ result = func(*args, **kwargs)
+ self._returns.append(result)
+ except Exception as e:
+ self._exceptions.append(e)
+ if self.print_exceptions:
+ print_exception(e)
+
+ @property
+ def returns(self):
+ return self._returns
+
+ @property
+ def exceptions(self):
+ return self._exceptions
+
+
+# https://gist.github.com/tliron/81dd915166b0bfc64be08b4f8e22c835
+class FixedThreadPoolExecutor(Executor):
+ """
+ Executes tasks in a fixed thread pool.
+ """
+
+ _CYANIDE = object() # special task marker used to kill worker threads
def __init__(self,
size=None,
@@ -105,6 +201,8 @@ class FixedThreadPoolExecutor(object):
:param timeout: timeout in seconds for all blocking operations (``None`` means no timeout)
:param print_exceptions: set to ``True`` in order to print exceptions from tasks
"""
+ super(FixedThreadPoolExecutor, self).__init__(print_exceptions=print_exceptions)
+
if not size:
try:
size = multiprocessing.cpu_count() * 2 + 1
@@ -113,7 +211,6 @@ class FixedThreadPoolExecutor(object):
self.size = size
self.timeout = timeout
- self.print_exceptions = print_exceptions
self._tasks = Queue()
self._returns = {}
@@ -130,28 +227,12 @@ class FixedThreadPoolExecutor(object):
self._workers.append(worker)
def submit(self, func, *args, **kwargs):
- """
- Submit a task for execution.
-
- The task will be called ASAP on the next available worker thread in the pool.
-
- :raises ExecutorException: if cannot be submitted
- """
-
try:
self._tasks.put((self._id_creator.next(), func, args, kwargs), timeout=self.timeout)
except Full:
raise ExecutorException('cannot submit task: queue is full')
def close(self):
- """
- Blocks until all current tasks finish execution and all worker threads are dead.
-
- You cannot submit tasks anymore after calling this.
-
- This is called automatically upon exit if you are using the ``with`` keyword.
- """
-
self.drain()
while self.is_alive:
try:
@@ -161,11 +242,7 @@ class FixedThreadPoolExecutor(object):
self._workers = None
def drain(self):
- """
- Blocks until all current tasks finish execution, but leaves the worker threads alive.
- """
-
- self._tasks.join() # oddly, the API does not support a timeout parameter
+ self._tasks.join() # oddly, the API does not support a timeout parameter
@property
def is_alive(self):
@@ -180,33 +257,12 @@ class FixedThreadPoolExecutor(object):
@property
def returns(self):
- """
- The returned values from all tasks, in order of submission.
- """
-
return [self._returns[k] for k in sorted(self._returns)]
@property
def exceptions(self):
- """
- The raised exceptions from all tasks, in order of submission.
- """
-
return [self._exceptions[k] for k in sorted(self._exceptions)]
- def raise_first(self):
- """
- If exceptions were thrown by any task, then the first one will be raised.
-
- This is rather arbitrary: proper handling would involve iterating all the exceptions.
- However, if you want to use the "raise" mechanism, you are limited to raising only one of
- them.
- """
-
- exceptions = self.exceptions
- if exceptions:
- raise exceptions[0]
-
def _thread_worker(self):
while True:
if not self._execute_next_task():
@@ -240,7 +296,6 @@ class FixedThreadPoolExecutor(object):
def __exit__(self, the_type, value, traceback):
self.close()
- return False
class LockedList(list):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/aria/utils/versions.py
----------------------------------------------------------------------
diff --git a/aria/utils/versions.py b/aria/utils/versions.py
index 521004c..507f055 100644
--- a/aria/utils/versions.py
+++ b/aria/utils/versions.py
@@ -24,7 +24,7 @@ _INF = float('inf')
_NULL = (), _INF
-_DIGITS_RE = re.compile(r'^\d+$')
+_DIGITS_RE = re.compile(r'^\d+$', flags=re.UNICODE)
_PREFIXES = {
'dev': 0.0001,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
index 34dacd6..f53a5cc 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
@@ -16,6 +16,7 @@
from aria.utils.formatting import safe_repr
from aria.utils.type import full_type_name
from aria.parser.exceptions import InvalidValueError
+from aria.parser.presentation import NULL
def data_type_class_getter(cls):
@@ -27,13 +28,14 @@ def data_type_class_getter(cls):
def getter(field, presentation, context=None):
raw = field.default_get(presentation, context)
- if raw is not None:
- try:
- return cls(None, None, raw, None)
- except ValueError as e:
- raise InvalidValueError(
- '{0} is not a valid "{1}" in "{2}": {3}'
- .format(field.full_name, full_type_name(cls), presentation._name,
- safe_repr(raw)),
- cause=e, locator=field.get_locator(raw))
+ if (raw is None) or (raw is NULL):
+ return raw
+ try:
+ return cls(None, None, raw, None)
+ except ValueError as e:
+ raise InvalidValueError(
+ '{0} is not a valid "{1}" in "{2}": {3}'
+ .format(field.full_name, full_type_name(cls), presentation._name,
+ safe_repr(raw)),
+ cause=e, locator=field.get_locator(raw))
return getter
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/extensions/aria_extension_tosca/simple_v1_0/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py
index 0241917..2d053b0 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -70,7 +70,7 @@ class ArtifactType(ExtensiblePresentation):
"""
@field_getter(data_type_class_getter(Version))
- @primitive_field()
+ @primitive_field(str)
def version(self):
"""
An optional version for the Artifact Type definition.
@@ -153,7 +153,8 @@ class DataType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Data Type definition.
@@ -250,7 +251,8 @@ class CapabilityType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Capability Type definition.
@@ -352,7 +354,8 @@ class InterfaceType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Interface Type definition.
@@ -431,7 +434,8 @@ class RelationshipType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Relationship Type definition.
@@ -546,7 +550,8 @@ class NodeType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Node Type definition.
@@ -702,7 +707,8 @@ class GroupType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Group Type definition.
@@ -808,7 +814,8 @@ class PolicyType(ExtensiblePresentation):
:type: :obj:`basestring`
"""
- @object_field(Version)
+ @field_getter(data_type_class_getter(Version))
+ @primitive_field(str)
def version(self):
"""
An optional version for the Policy Type definition.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
index 86bbc3f..399e8c8 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
@@ -13,16 +13,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+PyTest configuration module.
+"""
+
import pytest
from ....mechanisms.parsing.aria import AriaParser
+def pytest_addoption(parser):
+ parser.addoption('--tosca-parser', action='store', default='aria', help='TOSCA parser')
+
+
def pytest_report_header(config):
- return 'parser: ARIA'
+ tosca_parser = config.getoption('--tosca-parser')
+ return 'tosca-parser: {0}'.format(tosca_parser)
@pytest.fixture(scope='session')
-def parser():
- with AriaParser() as p:
- yield p
+def parser(request):
+ tosca_parser = request.config.getoption('--tosca-parser')
+ verbose = request.config.getoption('verbose') > 0
+ if tosca_parser == 'aria':
+ with AriaParser() as p:
+ p.verbose = verbose
+ yield p
+ else:
+ pytest.fail('configured tosca-parser not supported: {0}'.format(tosca_parser))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
new file mode 100644
index 0000000..b24fb29
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -0,0 +1,40 @@
+# -*- 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.
+
+
+NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
+NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
+NOT_A_STRING = ('123', '0.123', '[]', '{}')
+TYPE_NAMES = ('artifact', 'data', 'capability', 'interface', 'relationship', 'node', 'group',
+ 'policy')
+TYPE_NAME_PLURAL = {
+ 'artifact': 'artifacts',
+ 'data': 'datatypes',
+ 'capability': 'capabilities',
+ 'interface': 'interfaces',
+ 'relationship': 'relationships',
+ 'node': 'nodes',
+ 'group': 'groups',
+ 'policy': 'policies'
+}
+TEMPLATE_NAMES = ('node', 'group', 'policy')
+TEMPLATE_NAME_SECTION = {
+ 'node': 'node_templates',
+ 'group': 'groups',
+ 'policy': 'policies'
+}
+GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'")
+BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
index 4d78f40..765cd8b 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -16,9 +16,12 @@
import pytest
+from . import data
from ....mechanisms.web_server import WebServer
+# Fixtures
+
NODE_TYPE_IMPORT = """
node_types:
MyNode:
@@ -35,17 +38,16 @@ node_types:
def repository():
repository = WebServer()
repository.add_text_yaml('/imports/node-type.yaml', NODE_TYPE_IMPORT)
- repository.add_text_yaml('/imports/{0}.yaml'.format(WebServer.escape('詠嘆調')),
+ repository.add_text_yaml('/imports/{0}.yaml'.format(WebServer.escape('節點類型')),
NODE_TYPE_IMPORT)
repository.add_text_yaml('/imports/bad.yaml', BAD_IMPORT)
- repository.start()
- yield repository.root
- repository.stop()
+ with repository:
+ yield repository.root
# Syntax
-@pytest.mark.parametrize('value', ('null', 'a_string', '123', '0.123', '{}'))
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
def test_imports_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -53,7 +55,7 @@ imports: {{ value }}
""", dict(value=value)).assert_failure()
-def test_imports_empty_list(parser):
+def test_imports_empty(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
imports: []
@@ -75,10 +77,10 @@ topology_template:
def test_import_single_short_form_unicode(parser, repository):
- parser.parse_literal(u"""
+ parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
imports:
- - {{ repository }}/imports/詠嘆調.yaml
+ - {{ repository }}/imports/節點類型.yaml
topology_template:
node_templates:
my_node:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
index dae5631..3f89bf6 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
@@ -14,12 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import itertools
+
import pytest
+from . import data
+
# Syntax
-@pytest.mark.parametrize('value', ('null', 'a_string', '123', '0.123', '[]'))
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
def test_metadata_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -27,20 +31,11 @@ metadata: {{ value }}
""", dict(value=value)).assert_failure()
-@pytest.mark.parametrize('field,value', (
- ('template_name', '123'),
- ('template_name', '0.123'),
- ('template_name', '[]'),
- ('template_name', '{}'),
- ('template_author', '123'),
- ('template_author', '0.123'),
- ('template_author', '[]'),
- ('template_author', '{}'),
- ('template_version', '123'),
- ('template_version', '0.123'),
- ('template_version', '[]'),
- ('template_version', '{}')))
-def test_metadata_normative_wrong_yaml_type(parser, field, value):
+@pytest.mark.parametrize('field,value', itertools.product(
+ ('template_name', 'template_author', 'template_version'),
+ data.NOT_A_STRING
+))
+def test_metadata_normative_fields_wrong_yaml_type(parser, field, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
@@ -48,8 +43,8 @@ metadata:
""", dict(field=field, value=value)).assert_failure()
-@pytest.mark.parametrize('value', ('123', '0.123', '[]', '{}'))
-def test_metadata_non_normative_wrong_yaml_type(parser, value):
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_metadata_non_normative_fields_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
@@ -57,7 +52,7 @@ metadata:
""", dict(value=value)).assert_failure()
-def test_metadata_empty_dict(parser):
+def test_metadata_empty(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata: {}
@@ -66,22 +61,23 @@ metadata: {}
# Normative
-@pytest.mark.parametrize('value', ('null', 'a_string', '1.2.3.4.5'))
-def test_metadata_normative_template_bad_version(parser, value):
+@pytest.mark.parametrize('value', data.GOOD_VERSIONS)
+def test_metadata_normative_template_version(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
template_version: {{ value }}
-""", dict(value=value)).assert_failure()
+""", dict(value=value)).assert_success()
-@pytest.mark.parametrize('value', ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'"))
-def test_metadata_normative_template_version(parser, value):
+@pytest.mark.parametrize('value', data.BAD_VERSIONS)
+def test_metadata_normative_template_bad_version(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
template_version: {{ value }}
-""", dict(value=value)).assert_success()
+""", dict(value=value)).assert_failure()
+
# Non-normative
@@ -91,7 +87,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
template_name: name
template_author: author
- template_version: 1.0.0.beta
+ template_version: 1.0.0.alpha-10
non_normative1: non_normative1
non_normative2: non_normative2
non_normative3: non_normative3
@@ -104,7 +100,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
template_name: null
template_author: null
- template_version: 1.0.0.beta
+ template_version: null
non_normative1: null
non_normative2: null
non_normative3: null
@@ -112,13 +108,13 @@ metadata:
def test_metadata_with_non_normative_fields_unicode(parser):
- parser.parse_literal(u"""
+ parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
metadata:
template_name: 詠嘆調
template_author: 詠嘆調
- template_version: 1.0.0.詠嘆調
- non_normative1: 詠嘆調
- non_normative2: 詠嘆調
- non_normative3: 詠嘆調
+ template_version: 1.0.0.詠嘆調-10
+ non_normative1: 詠嘆調一
+ non_normative2: 詠嘆調二
+ non_normative3: 詠嘆調三
""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
new file mode 100644
index 0000000..8b0fd0e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
@@ -0,0 +1,129 @@
+# -*- 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 itertools
+
+import pytest
+
+from . import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_topology_template_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_topology_template_emtpy(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template: {}
+""").assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_DICT
+))
+def test_template_section_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: tosca.{{ plural }}.Root
+ description: a description
+""", dict(section=data.TEMPLATE_NAME_SECTION[name],
+ plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Of types
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_type_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型: {}
+topology_template:
+ {{ section }}:
+ 模板:
+ type: 類型
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_unknown_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: UnknownType
+""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_null_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: null
+""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
new file mode 100644
index 0000000..0699e1e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
@@ -0,0 +1,153 @@
+# -*- 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 itertools
+
+import pytest
+
+from . import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+
+# Derivation
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: UnknownType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_null(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: null
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_self(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: MyType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_circular(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ derived_from: MyType3
+ MyType2:
+ derived_from: MyType1
+ MyType3:
+ derived_from: MyType2
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_root(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0
+ description: a description
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.BAD_VERSIONS
+))
+def test_type_bad_version(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/mechanisms/parsing/__init__.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/parsing/__init__.py b/tests/mechanisms/parsing/__init__.py
index c1525a8..b2b5146 100644
--- a/tests/mechanisms/parsing/__init__.py
+++ b/tests/mechanisms/parsing/__init__.py
@@ -14,33 +14,51 @@
# limitations under the License.
import pytest
-from jinja2 import Template
+import jinja2
+
+
+LINE_BREAK = '\n' + '-' * 60
class Parsed(object):
def __init__(self):
self.issues = []
self.text = ''
+ self.verbose = False
def assert_success(self):
__tracebackhide__ = True # pylint: disable=unused-variable
if len(self.issues) > 0:
pytest.fail(u'did not expect parsing errors\n\n{0}\n\n{1}'
.format(self.text.strip(), u'\n'.join(self.issues)))
+ else:
+ if self.verbose:
+ print LINE_BREAK
+ print self.text.strip()
def assert_failure(self):
__tracebackhide__ = True # pylint: disable=unused-variable
if len(self.issues) > 0:
- pass
+ if self.verbose:
+ print LINE_BREAK
+ print u'{0}\n\n{1}'.format(self.text.strip(), u'\n'.join(self.issues))
else:
pytest.fail(u'expected parsing errors but got none\n\n{0}'
.format(self.text.strip()))
class Parser(object):
+ def __init__(self):
+ self.verbose = False
+
def parse_literal(self, text, context=None):
text = render(text, context)
- return self._parse_literal(text)
+ parsed = self._parse_literal(text)
+ parsed.verbose = self.verbose
+ return parsed
+
+ def _parse_literal(self, text):
+ raise NotImplementedError
def __enter__(self):
return self
@@ -50,6 +68,8 @@ class Parser(object):
def render(template, context=None):
- template = Template(template)
+ if not isinstance(template, unicode):
+ template = template.decode('utf-8')
+ template = jinja2.Template(template)
template = template.render(context or {})
return template
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/mechanisms/parsing/aria.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/parsing/aria.py b/tests/mechanisms/parsing/aria.py
index c02d387..63aadb7 100644
--- a/tests/mechanisms/parsing/aria.py
+++ b/tests/mechanisms/parsing/aria.py
@@ -25,7 +25,7 @@ from aria.parser.consumption import (
)
from aria.utils.imports import import_fullname
-from . import Parser, Parsed
+from . import (Parser, Parsed)
class AriaParser(Parser):
@@ -51,6 +51,7 @@ class AriaParser(Parser):
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.print_exceptions = debug
return context
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/mechanisms/web_server.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/web_server.py b/tests/mechanisms/web_server.py
index 7db901e..8a50ae7 100644
--- a/tests/mechanisms/web_server.py
+++ b/tests/mechanisms/web_server.py
@@ -19,6 +19,7 @@ import threading
import tornado.web
import tornado.ioloop
import tornado.netutil
+import tornado.httpserver
logging.getLogger('tornado.access').disabled = True
@@ -43,7 +44,7 @@ class WebServer(threading.Thread):
def root(self):
return 'http://localhost:{0}'.format(self.port)
- def add_text(self, url, content, content_type):
+ def add_text(self, url, content, content_type='text/plain'):
self.content.append((url, TextHandler, dict(content=content, content_type=content_type)))
def add_text_yaml(self, url, content):
@@ -65,6 +66,14 @@ class WebServer(threading.Thread):
def escape(segment):
return tornado.escape.url_escape(segment)
+ def __enter__(self):
+ self.start()
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.stop()
+
+
class TextHandler(tornado.web.RequestHandler):
def initialize(self, content, content_type): # pylint: disable=arguments-differ
self.content = content
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/parser/utils.py
----------------------------------------------------------------------
diff --git a/tests/parser/utils.py b/tests/parser/utils.py
index f0e890f..5a98cf2 100644
--- a/tests/parser/utils.py
+++ b/tests/parser/utils.py
@@ -39,6 +39,7 @@ def create_context(uri,
context.presentation.location = UriLocation(uri) if isinstance(uri, basestring) else uri
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.print_exceptions = debug
return context
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/requirements.txt
----------------------------------------------------------------------
diff --git a/tests/requirements.txt b/tests/requirements.txt
index bdd5e2c..f98ea97 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -16,8 +16,8 @@ sh==1.12.14
tornado==4.3 # last release to support Python 2.6
psutil==5.2.2
mock==2.0.0
-pylint==1.6.5
-pytest==3.2.0
+pylint==1.6.5 # see ARIA-314 about upgrading to 1.7
+pytest==3.2.1
pytest-cov==2.5.1
pytest-mock==1.6.2
-pytest-xdist==1.18.2
+pytest-xdist==1.20.0
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml
----------------------------------------------------------------------
diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml
index 5a46532..ef62676 100644
--- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml
+++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml
@@ -19,7 +19,7 @@ tosca_definitions_version: tosca_simple_profile_for_nfv_1_0
description: >-
Node Cellar TOSCA blueprint.
- Here is some Unicode: 中國.
+ Here is some Unicode: 詠嘆調.
metadata:
template_name: node-cellar
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tests/utils/test_versions.py
----------------------------------------------------------------------
diff --git a/tests/utils/test_versions.py b/tests/utils/test_versions.py
index 222949c..bcbf9ef 100644
--- a/tests/utils/test_versions.py
+++ b/tests/utils/test_versions.py
@@ -1,3 +1,4 @@
+# -*- 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.
@@ -34,8 +35,11 @@ def test_version_string():
assert VersionString('20.0.1-beta1') < VersionString('20.0.1')
assert VersionString('20.0.1-beta2') < VersionString('20.0.1-rc2')
assert VersionString('20.0.1-alpha2') < VersionString('20.0.1-beta1')
- assert VersionString('20.0.1-dev2') < VersionString('20.0.1-alpha1')
- assert VersionString('20.0.1-DEV2') < VersionString('20.0.1-ALPHA1')
+ assert VersionString('20.0.1-dev2') < VersionString('20.0.1-ALPHA1')
+ assert VersionString('20.0.1-DEV2') < VersionString('20.0.1-alpha1')
+
+ # With Unicode qualifier
+ assert VersionString(u'20.0.1-詠嘆調1') == VersionString(u'20.0.1-詠嘆調2')
# Coercive comparisons
assert VersionString('20.0.0') == VersionString(10 * 2)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9d1183ac/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index ff71e05..1adb4ce 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,7 +11,7 @@
# limitations under the License.
[tox]
-envlist=py27,py26,py27e2e,py26e2e,pywin,py27ssh,pylint_code,pylint_tests,docs
+envlist=py27,py26,py27e2e,py26e2e,py27extensions,py26extensions,py27ssh,py26ssh,pywin,pylint_code,pylint_tests,docs
processes={env:PYTEST_PROCESSES:auto}
[testenv]
@@ -28,12 +28,14 @@ deps=
--requirement
tests/requirements.txt
basepython=
- py26: python2.6
py27: python2.7
- py26e2e: python2.6
+ py26: python2.6
py27e2e: python2.7
- py26ssh: python2.6
+ py26e2e: python2.6
+ py27extensions: python2.7
+ py26extensions: python2.6
py27ssh: python2.7
+ py26ssh: python2.6
pywin: {env:PYTHON:}\python.exe
pylint_code: python2.7
pylint_tests: python2.7
@@ -44,6 +46,7 @@ commands=
pytest tests \
--numprocesses={[tox]processes} \
--ignore=tests/end2end \
+ --ignore=tests/extensions \
--ignore=tests/orchestrator/execution_plugin/test_ssh.py \
--cov-report term-missing \
--cov aria
@@ -53,6 +56,7 @@ commands=
pytest tests \
--numprocesses={[tox]processes} \
--ignore=tests/end2end \
+ --ignore=tests/extensions \
--ignore=tests/orchestrator/execution_plugin/test_ssh.py \
--cov-report term-missing \
--cov aria
@@ -71,14 +75,19 @@ commands=
--cov-report term-missing \
--cov aria
-[testenv:pywin]
+[testenv:py27extensions]
commands=
- pytest tests \
+ pytest tests/extensions \
--numprocesses={[tox]processes} \
- --ignore=tests/end2end \
- --ignore=tests/orchestrator/execution_plugin/test_ssh.py \
--cov-report term-missing \
- --cov aria
+ --cov extensions
+
+[testenv:py26extensions]
+commands=
+ pytest tests/extensions \
+ --numprocesses={[tox]processes} \
+ --cov-report term-missing \
+ --cov extensions
[testenv:py27ssh]
install_command=
@@ -94,9 +103,19 @@ commands=
pytest tests/orchestrator/execution_plugin/test_ssh.py \
--numprocesses={[tox]processes}
+[testenv:pywin]
+commands=
+ pytest tests \
+ --numprocesses={[tox]processes} \
+ --ignore=tests/end2end \
+ --ignore=tests/extensions \
+ --ignore=tests/orchestrator/execution_plugin/test_ssh.py \
+ --cov-report term-missing \
+ --cov aria
+
[testenv:pylint_code]
commands=
- pylint aria extensions/aria_extension_tosca/ \
+ pylint aria extensions/aria_extension_tosca \
--rcfile=aria/.pylintrc \
--disable=fixme,missing-docstring
[05/10] incubator-ariatosca git commit: Initial work on mechanism,
imports, and metadata
Posted by em...@apache.org.
Initial work on mechanism, imports, and metadata
* Metadata 'template_version' is now version data type
* Unicode support for version
* Better Unicode support for validation issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/36e0aa56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/36e0aa56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/36e0aa56
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 36e0aa56615cbf0f836c2fdcfce6c21323b511aa
Parents: 969149b
Author: Tal Liron <ta...@gmail.com>
Authored: Thu Aug 17 17:50:27 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500
----------------------------------------------------------------------
aria/modeling/service_common.py | 6 +-
aria/parser/validation/issue.py | 4 +-
.../simple_v1_0/data_types.py | 21 ++-
.../aria_extension_tosca/simple_v1_0/misc.py | 9 +-
.../simple_v1_0/presentation/field_getters.py | 6 +-
tests/extensions/__init__.py | 14 ++
.../extensions/aria_extension_tosca/__init__.py | 14 ++
.../simple_v1_0/__init__.py | 14 ++
.../simple_v1_0/conftest.py | 28 ++++
.../simple_v1_0/test_imports.py | 152 +++++++++++++++++++
.../simple_v1_0/test_metadata.py | 124 +++++++++++++++
tests/mechanisms/__init__.py | 14 ++
tests/mechanisms/parsing/__init__.py | 55 +++++++
tests/mechanisms/parsing/aria.py | 63 ++++++++
tests/mechanisms/web_server.py | 75 +++++++++
tests/requirements.txt | 1 +
16 files changed, 578 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index 478e530..0cc88f4 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -22,7 +22,8 @@ ARIA modeling service common module
from sqlalchemy import (
Column,
Text,
- Boolean
+ Boolean,
+ PickleType
)
from sqlalchemy.ext.declarative import declared_attr
@@ -587,12 +588,11 @@ class MetadataBase(TemplateModelMixin):
:ivar name: name
:vartype name: basestring
:ivar value: value
- :vartype value: basestring
"""
__tablename__ = 'metadata'
- value = Column(Text)
+ value = Column(PickleType)
@property
def as_raw(self):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/aria/parser/validation/issue.py
----------------------------------------------------------------------
diff --git a/aria/parser/validation/issue.py b/aria/parser/validation/issue.py
index 42fc580..cc68737 100644
--- a/aria/parser/validation/issue.py
+++ b/aria/parser/validation/issue.py
@@ -66,9 +66,9 @@ class Issue(object):
def __init__(self, message=None, exception=None, location=None, line=None,
column=None, locator=None, snippet=None, level=0):
if message is not None:
- self.message = str(message)
+ self.message = unicode(message)
elif exception is not None:
- self.message = str(exception)
+ self.message = unicode(exception)
else:
self.message = 'unknown issue'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/extensions/aria_extension_tosca/simple_v1_0/data_types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/data_types.py b/extensions/aria_extension_tosca/simple_v1_0/data_types.py
index 513b517..23417b0 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/data_types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/data_types.py
@@ -41,7 +41,7 @@ class Timezone(tzinfo):
return self._offset
def tzname(self, dt): # pylint: disable=unused-argument
- return str(self._offset)
+ return unicode(self._offset)
def dst(self, dt): # pylint: disable=unused-argument
return Timezone._ZERO
@@ -75,7 +75,7 @@ class Timestamp(object):
CANONICAL = '%Y-%m-%dT%H:%M:%S'
def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
- value = str(value)
+ value = unicode(value)
match = re.match(Timestamp.REGULAR_SHORT, value)
if match is not None:
# Parse short form
@@ -165,7 +165,7 @@ class Version(object):
REGULAR = \
r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<fix>\d+)' + \
- r'((\.(?P<qualifier>\d+))(\-(?P<build>\d+))?)?)?$'
+ r'((\.(?P<qualifier>\w+))(\-(?P<build>\d+))?)?)?$'
@staticmethod
def key(version):
@@ -175,8 +175,8 @@ class Version(object):
return (version.major, version.minor, version.fix, version.qualifier, version.build)
def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
- str_value = str(value)
- match = re.match(Version.REGULAR, str_value)
+ str_value = unicode(value)
+ match = re.match(Version.REGULAR, str_value, flags=re.UNICODE)
if match is None:
raise ValueError(
'version must be formatted as <major_version>.<minor_version>'
@@ -193,8 +193,6 @@ class Version(object):
if self.fix is not None:
self.fix = int(self.fix)
self.qualifier = match.group('qualifier')
- if self.qualifier is not None:
- self.qualifier = int(self.qualifier)
self.build = match.group('build')
if self.build is not None:
self.build = int(self.build)
@@ -215,6 +213,7 @@ class Version(object):
return (self.major, self.minor, self.fix, self.qualifier, self.build) == \
(version.major, version.minor, version.fix, version.qualifier, version.build)
+ @implements_specification('3.2.2.1', 'tosca-simple-1.0')
def __lt__(self, version):
if self.major < version.major:
return True
@@ -225,9 +224,7 @@ class Version(object):
if self.fix < version.fix:
return True
elif self.fix == version.fix:
- if self.qualifier < version.qualifier:
- return True
- elif self.qualifier == version.qualifier:
+ if self.qualifier == version.qualifier:
if self.build < version.build:
return True
return False
@@ -375,8 +372,8 @@ class Scalar(object):
return scalar.value
def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
- str_value = str(value)
- match = re.match(self.REGULAR, str_value) # pylint: disable=no-member
+ str_value = unicode(value)
+ match = re.match(self.REGULAR, str_value, flags=re.UNICODE) # pylint: disable=no-member
if match is None:
raise ValueError('scalar must be formatted as <scalar> <unit>: %s' % safe_repr(value))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/extensions/aria_extension_tosca/simple_v1_0/misc.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/misc.py b/extensions/aria_extension_tosca/simple_v1_0/misc.py
index 221163c..418fe31 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -20,14 +20,16 @@ from aria.parser import implements_specification
from aria.parser.presentation import (AsIsPresentation, has_fields, allow_unknown_fields,
short_form_field, primitive_field, primitive_list_field,
primitive_dict_unknown_fields, object_field,
- object_list_field, object_dict_field, field_validator,
- type_validator)
+ object_list_field, object_dict_field, field_getter,
+ field_validator, type_validator)
+from .data_types import Version
from .modeling.data_types import (get_data_type, get_data_type_value, get_property_constraints,
apply_constraint_to_value)
from .modeling.substitution_mappings import (validate_substitution_mappings_requirement,
validate_substitution_mappings_capability)
from .presentation.extensible import ExtensiblePresentation
+from .presentation.field_getters import data_type_class_getter
from .presentation.field_validators import (constraint_clause_field_validator,
constraint_clause_in_range_validator,
constraint_clause_valid_values_validator,
@@ -79,6 +81,7 @@ class MetaData(ExtensiblePresentation):
as a single-line string value.
"""
+ @field_getter(data_type_class_getter(Version))
@primitive_field(str)
@implements_specification('3.9.3.5', 'tosca-simple-1.0')
def template_version(self):
@@ -87,7 +90,7 @@ class MetaData(ExtensiblePresentation):
service template as a single-line string value.
"""
- @primitive_dict_unknown_fields()
+ @primitive_dict_unknown_fields(str)
def custom(self):
"""
:type: dict
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
index f14164a..34dacd6 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
@@ -14,6 +14,7 @@
# limitations under the License.
from aria.utils.formatting import safe_repr
+from aria.utils.type import full_type_name
from aria.parser.exceptions import InvalidValueError
@@ -31,7 +32,8 @@ def data_type_class_getter(cls):
return cls(None, None, raw, None)
except ValueError as e:
raise InvalidValueError(
- '%s is not a valid "%s" in "%s": %s'
- % (field.full_name, field.full_cls_name, presentation._name, safe_repr(raw)),
+ '{0} is not a valid "{1}" in "{2}": {3}'
+ .format(field.full_name, full_type_name(cls), presentation._name,
+ safe_repr(raw)),
cause=e, locator=field.get_locator(raw))
return getter
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/__init__.py b/tests/extensions/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/aria_extension_tosca/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/__init__.py b/tests/extensions/aria_extension_tosca/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/aria_extension_tosca/simple_v1_0/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
new file mode 100644
index 0000000..86bbc3f
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
@@ -0,0 +1,28 @@
+# 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 ....mechanisms.parsing.aria import AriaParser
+
+
+def pytest_report_header(config):
+ return 'parser: ARIA'
+
+
+@pytest.fixture(scope='session')
+def parser():
+ with AriaParser() as p:
+ yield p
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
new file mode 100644
index 0000000..4d78f40
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -0,0 +1,152 @@
+# -*- 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 ....mechanisms.web_server import WebServer
+
+
+NODE_TYPE_IMPORT = """
+node_types:
+ MyNode:
+ derived_from: tosca.nodes.Root
+"""
+
+BAD_IMPORT = """
+node_types:
+ MyNode:
+ derived_from: not.a.node.type
+"""
+
+@pytest.fixture(scope='session')
+def repository():
+ repository = WebServer()
+ repository.add_text_yaml('/imports/node-type.yaml', NODE_TYPE_IMPORT)
+ repository.add_text_yaml('/imports/{0}.yaml'.format(WebServer.escape('詠嘆調')),
+ NODE_TYPE_IMPORT)
+ repository.add_text_yaml('/imports/bad.yaml', BAD_IMPORT)
+ repository.start()
+ yield repository.root
+ repository.stop()
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', ('null', 'a_string', '123', '0.123', '{}'))
+def test_imports_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_imports_empty_list(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports: []
+""").assert_success()
+
+
+# Variants
+
+def test_import_single_short_form(parser, repository):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - {{ repository }}/imports/node-type.yaml
+topology_template:
+ node_templates:
+ my_node:
+ type: MyNode
+""", dict(repository=repository)).assert_success()
+
+
+def test_import_single_short_form_unicode(parser, repository):
+ parser.parse_literal(u"""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - {{ repository }}/imports/詠嘆調.yaml
+topology_template:
+ node_templates:
+ my_node:
+ type: MyNode
+""", dict(repository=repository)).assert_success()
+
+
+def test_import_single_long_form(parser, repository):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - file: {{ repository }}/imports/node-type.yaml
+topology_template:
+ node_templates:
+ my_node:
+ type: MyNode
+""", dict(repository=repository)).assert_success()
+
+
+@pytest.mark.skip(reason='not yet supported')
+def test_import_single_repository(parser, repository):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ myrepository:
+ url: {{ repository }}/imports/
+imports:
+ - file: node-type.yaml
+ repository: myrepository
+topology_template:
+ node_templates:
+ my_node:
+ type: MyNode
+""", dict(repository=repository)).assert_success()
+
+
+@pytest.mark.skip(reason='not yet supported')
+def test_import_single_namespace(parser, repository):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - file: {{ repository }}/imports/node-type.yaml
+ namespace_uri:
+ namespace_prefix: my_namespace
+topology_template:
+ node_templates:
+ my_node:
+ type: my_namespace.MyNode
+""", dict(repository=repository)).assert_success()
+
+
+# Failures
+
+def test_import_not_found(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - does_not_exist
+""").assert_failure()
+
+
+def test_import_bad(parser, repository):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+imports:
+ - {{ repository }}/imports/bad.yaml
+topology_template:
+ node_templates:
+ my_node:
+ type: MyNode
+""", dict(repository=repository)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
new file mode 100644
index 0000000..dae5631
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_metadata.py
@@ -0,0 +1,124 @@
+# -*- 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
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', ('null', 'a_string', '123', '0.123', '[]'))
+def test_metadata_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('field,value', (
+ ('template_name', '123'),
+ ('template_name', '0.123'),
+ ('template_name', '[]'),
+ ('template_name', '{}'),
+ ('template_author', '123'),
+ ('template_author', '0.123'),
+ ('template_author', '[]'),
+ ('template_author', '{}'),
+ ('template_version', '123'),
+ ('template_version', '0.123'),
+ ('template_version', '[]'),
+ ('template_version', '{}')))
+def test_metadata_normative_wrong_yaml_type(parser, field, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ {{ field }}: {{ value }}
+""", dict(field=field, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', ('123', '0.123', '[]', '{}'))
+def test_metadata_non_normative_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ non_normative: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_metadata_empty_dict(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata: {}
+""").assert_success()
+
+
+# Normative
+
+@pytest.mark.parametrize('value', ('null', 'a_string', '1.2.3.4.5'))
+def test_metadata_normative_template_bad_version(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ template_version: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'"))
+def test_metadata_normative_template_version(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ template_version: {{ value }}
+""", dict(value=value)).assert_success()
+
+# Non-normative
+
+def test_metadata_with_non_normative_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ template_name: name
+ template_author: author
+ template_version: 1.0.0.beta
+ non_normative1: non_normative1
+ non_normative2: non_normative2
+ non_normative3: non_normative3
+""").assert_success()
+
+
+def test_metadata_with_non_normative_fields_nulls(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ template_name: null
+ template_author: null
+ template_version: 1.0.0.beta
+ non_normative1: null
+ non_normative2: null
+ non_normative3: null
+""").assert_success()
+
+
+def test_metadata_with_non_normative_fields_unicode(parser):
+ parser.parse_literal(u"""
+tosca_definitions_version: tosca_simple_yaml_1_0
+metadata:
+ template_name: 詠嘆調
+ template_author: 詠嘆調
+ template_version: 1.0.0.詠嘆調
+ non_normative1: 詠嘆調
+ non_normative2: 詠嘆調
+ non_normative3: 詠嘆調
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/mechanisms/__init__.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/__init__.py b/tests/mechanisms/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/mechanisms/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/mechanisms/parsing/__init__.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/parsing/__init__.py b/tests/mechanisms/parsing/__init__.py
new file mode 100644
index 0000000..c1525a8
--- /dev/null
+++ b/tests/mechanisms/parsing/__init__.py
@@ -0,0 +1,55 @@
+# 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 jinja2 import Template
+
+
+class Parsed(object):
+ def __init__(self):
+ self.issues = []
+ self.text = ''
+
+ def assert_success(self):
+ __tracebackhide__ = True # pylint: disable=unused-variable
+ if len(self.issues) > 0:
+ pytest.fail(u'did not expect parsing errors\n\n{0}\n\n{1}'
+ .format(self.text.strip(), u'\n'.join(self.issues)))
+
+ def assert_failure(self):
+ __tracebackhide__ = True # pylint: disable=unused-variable
+ if len(self.issues) > 0:
+ pass
+ else:
+ pytest.fail(u'expected parsing errors but got none\n\n{0}'
+ .format(self.text.strip()))
+
+
+class Parser(object):
+ def parse_literal(self, text, context=None):
+ text = render(text, context)
+ return self._parse_literal(text)
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ pass
+
+
+def render(template, context=None):
+ template = Template(template)
+ template = template.render(context or {})
+ return template
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/mechanisms/parsing/aria.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/parsing/aria.py b/tests/mechanisms/parsing/aria.py
new file mode 100644
index 0000000..c02d387
--- /dev/null
+++ b/tests/mechanisms/parsing/aria.py
@@ -0,0 +1,63 @@
+# 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.
+
+from __future__ import absolute_import # so we can import root 'aria'
+
+from aria.parser.loading import LiteralLocation
+from aria.parser.consumption import (
+ ConsumptionContext,
+ ConsumerChain,
+ Read,
+ Validate,
+ ServiceTemplate
+)
+from aria.utils.imports import import_fullname
+
+from . import Parser, Parsed
+
+
+class AriaParser(Parser):
+ def _parse_literal(self, text):
+ context = AriaParser.create_context()
+ context.presentation.location = LiteralLocation(text)
+ consumer = AriaParser.create_consumer(context)
+ consumer.consume()
+ parsed = Parsed()
+ parsed.text = text
+ for issue in context.validation.issues:
+ parsed.issues.append(unicode(issue))
+ return parsed
+
+ @staticmethod
+ def create_context(loader_source='aria.parser.loading.DefaultLoaderSource',
+ reader_source='aria.parser.reading.DefaultReaderSource',
+ presenter_source='aria.parser.presentation.DefaultPresenterSource',
+ presenter=None,
+ debug=False):
+ 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.print_exceptions = debug
+ return context
+
+ @staticmethod
+ def create_consumer(context):
+ return ConsumerChain(context, (
+ Read,
+ Validate,
+ ServiceTemplate
+ ))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/mechanisms/web_server.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/web_server.py b/tests/mechanisms/web_server.py
new file mode 100644
index 0000000..7db901e
--- /dev/null
+++ b/tests/mechanisms/web_server.py
@@ -0,0 +1,75 @@
+# 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 logging
+import threading
+
+import tornado.web
+import tornado.ioloop
+import tornado.netutil
+
+
+logging.getLogger('tornado.access').disabled = True
+
+
+class WebServer(threading.Thread):
+ def __init__(self):
+ super(WebServer, self).__init__()
+ self.daemon = True
+
+ self.content = []
+
+ # Arbitrary free socket
+ self.sockets = tornado.netutil.bind_sockets(0, '')
+ for s in self.sockets:
+ name = s.getsockname()
+ if name[0] == '0.0.0.0': # IPv4 (IPv6 would be '::')
+ self.port = name[1]
+ break
+
+ @property
+ def root(self):
+ return 'http://localhost:{0}'.format(self.port)
+
+ def add_text(self, url, content, content_type):
+ self.content.append((url, TextHandler, dict(content=content, content_type=content_type)))
+
+ def add_text_yaml(self, url, content):
+ self.add_text(url, content, 'application/x-yaml')
+
+ def stop(self):
+ self.ioloop.add_callback(self.ioloop.stop)
+
+ def run(self): # Thread override
+ application = tornado.web.Application(self.content)
+ server = tornado.httpserver.HTTPServer(application)
+ server.add_sockets(self.sockets)
+ self.ioloop = tornado.ioloop.IOLoop.current()
+ print 'Tornado starting'
+ self.ioloop.start()
+ print 'Tornado stopped'
+
+ @staticmethod
+ def escape(segment):
+ return tornado.escape.url_escape(segment)
+
+class TextHandler(tornado.web.RequestHandler):
+ def initialize(self, content, content_type): # pylint: disable=arguments-differ
+ self.content = content
+ self.content_type = content_type
+
+ def get(self):
+ self.write(self.content)
+ self.set_header('Content-Type', self.content_type)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36e0aa56/tests/requirements.txt
----------------------------------------------------------------------
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 56a7bf5..bdd5e2c 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -13,6 +13,7 @@
testtools==2.3.0
fasteners==0.14.1
sh==1.12.14
+tornado==4.3 # last release to support Python 2.6
psutil==5.2.2
mock==2.0.0
pylint==1.6.5
[10/10] incubator-ariatosca git commit: Most type tests complete
Posted by em...@apache.org.
Most type tests complete
Allow some datatype-typed fields to accept nulls
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/75225e88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/75225e88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/75225e88
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 75225e88157db38ff241a94556a1695c466034dd
Parents: 8b7f660
Author: Tal Liron <ta...@gmail.com>
Authored: Wed Aug 30 17:12:18 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 17:12:18 2017 -0500
----------------------------------------------------------------------
aria/parser/presentation/fields.py | 3 +-
.../simple_v1_0/definitions.py | 22 +
.../aria_extension_tosca/simple_v1_0/misc.py | 2 +-
.../simple_v1_0/presentation/field_getters.py | 4 +-
.../aria_extension_tosca/simple_v1_0/types.py | 18 +-
.../aria_extension_tosca/simple_v1_0/data.py | 43 +-
.../templates/test_template_parameters.py | 169 +++++
.../simple_v1_0/test_imports.py | 2 +-
.../simple_v1_0/types/common/__init__.py | 14 -
.../types/common/test_type_interfaces.py | 413 ------------
.../types/common/test_type_parameters.py | 334 ----------
.../simple_v1_0/types/common/test_types.py | 152 -----
.../types/node_types/test_node_type.py | 10 -
.../node_types/test_node_type_capabilities.py | 259 ++++++--
.../test_node_type_relationship_interfaces.py | 650 +++++++++++++++++++
.../node_types/test_node_type_requirements.py | 231 ++++++-
.../simple_v1_0/types/test_artifact_type.py | 74 +++
.../simple_v1_0/types/test_capability_type.py | 83 +++
.../simple_v1_0/types/test_group_type.py | 83 +++
.../simple_v1_0/types/test_policy_type.py | 121 ++++
.../simple_v1_0/types/test_relationship_type.py | 83 +++
.../simple_v1_0/types/test_type_interfaces.py | 438 +++++++++++++
.../simple_v1_0/types/test_type_parameters.py | 165 +++++
.../simple_v1_0/types/test_types.py | 152 +++++
24 files changed, 2546 insertions(+), 979 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/aria/parser/presentation/fields.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/fields.py b/aria/parser/presentation/fields.py
index c4b0c13..dc8894b 100644
--- a/aria/parser/presentation/fields.py
+++ b/aria/parser/presentation/fields.py
@@ -473,8 +473,7 @@ class Field(object):
# Handle get according to variant
- getter = getattr(self, '_get_{field_variant}'.format(field_variant=self.field_variant),
- None)
+ getter = getattr(self, '_get_{0}'.format(self.field_variant), None)
if getter is None:
locator = self.get_locator(raw)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/definitions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/definitions.py b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
index c1a2a66..36e0c47 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
@@ -15,7 +15,9 @@
from aria.utils.collections import FrozenDict
from aria.utils.caching import cachedmethod
+from aria.utils.formatting import safe_repr
from aria.parser import implements_specification
+from aria.parser.validation import Issue
from aria.parser.presentation import (has_fields, short_form_field, allow_unknown_fields,
primitive_field, primitive_list_field, object_field,
object_list_field, object_dict_field,
@@ -430,6 +432,16 @@ class RequirementDefinition(ExtensiblePresentation):
def _get_node_type(self, context):
return context.presentation.get_from_dict('service_template', 'node_types', self.node)
+ def _validate(self, context):
+ super(RequirementDefinition, self)._validate(context)
+ occurrences = self.occurrences
+ if (occurrences is not None) and ((occurrences.value[0] < 0) or \
+ ((occurrences.value[1] != 'UNBOUNDED') and (occurrences.value[1] < 0))):
+ context.validation.report(
+ 'requirements definition "{0}" occurrences range includes negative integers: {1}'
+ .format(self._name, safe_repr(occurrences)),
+ locator=self._locator, level=Issue.BETWEEN_TYPES)
+
@short_form_field('type')
@has_fields
@@ -518,3 +530,13 @@ class CapabilityDefinition(ExtensiblePresentation):
if container_parent is not None else None
return container_parent_capabilities.get(self._name) \
if container_parent_capabilities is not None else None
+
+ def _validate(self, context):
+ super(CapabilityDefinition, self)._validate(context)
+ occurrences = self.occurrences
+ if (occurrences is not None) and ((occurrences.value[0] < 0) or \
+ ((occurrences.value[1] != 'UNBOUNDED') and (occurrences.value[1] < 0))):
+ context.validation.report(
+ 'capability definition "{0}" occurrences range includes negative integers: {1}'
+ .format(self._name, safe_repr(occurrences)),
+ locator=self._locator, level=Issue.BETWEEN_TYPES)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/misc.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/misc.py b/extensions/aria_extension_tosca/simple_v1_0/misc.py
index 418fe31..997a5b6 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -81,7 +81,7 @@ class MetaData(ExtensiblePresentation):
as a single-line string value.
"""
- @field_getter(data_type_class_getter(Version))
+ @field_getter(data_type_class_getter(Version, allow_null=True))
@primitive_field(str)
@implements_specification('3.9.3.5', 'tosca-simple-1.0')
def template_version(self):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
index f53a5cc..6c424a4 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
@@ -19,7 +19,7 @@ from aria.parser.exceptions import InvalidValueError
from aria.parser.presentation import NULL
-def data_type_class_getter(cls):
+def data_type_class_getter(cls, allow_null=False):
"""
Wraps the field value in a specialized data type class.
@@ -28,7 +28,7 @@ def data_type_class_getter(cls):
def getter(field, presentation, context=None):
raw = field.default_get(presentation, context)
- if (raw is None) or (raw is NULL):
+ if (raw is None) or (allow_null and (raw is NULL)):
return raw
try:
return cls(None, None, raw, None)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py
index 2d053b0..5e4daee 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -303,7 +303,9 @@ class CapabilityType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, other_type):
- """returns True iff `other_type` is a descendant of the represented capability type"""
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if other_type is None:
return False
elif other_type._name == self._name:
@@ -315,12 +317,17 @@ class CapabilityType(ExtensiblePresentation):
return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
+ def _get_attributes(self, context):
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'attributes'))
+
+ @cachedmethod
def _get_valid_source_types(self, context):
return get_inherited_valid_source_types(context, self)
def _validate(self, context):
super(CapabilityType, self)._validate(context)
self._get_properties(context)
+ self._get_attributes(context)
def _dump(self, context):
self._dump_content(context, (
@@ -493,6 +500,9 @@ class RelationshipType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
@@ -625,6 +635,9 @@ class NodeType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
@@ -762,6 +775,9 @@ class GroupType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
index 1edb5e3..93e4d2e 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -15,9 +15,8 @@
# limitations under the License.
-NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
-NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
-NOT_A_STRING = ('123', '0.123', '[]', '{}')
+# Keywords
+
TYPE_NAMES = ('artifact', 'data', 'capability', 'interface', 'relationship', 'node', 'group',
'policy')
TYPE_NAME_PLURAL = {
@@ -36,6 +35,44 @@ TEMPLATE_NAME_SECTION = {
'group': 'groups',
'policy': 'policies'
}
+PARAMETER_SECTION_NAMES = ('properties', 'attributes')
+PARAMETER_SECTIONS = (
+ ('artifact', 'properties'),
+ ('data', 'properties'),
+ ('capability', 'properties'),
+ ('capability', 'attributes'),
+ ('interface', 'inputs'),
+ ('relationship', 'properties'),
+ ('relationship', 'attributes'),
+ ('node', 'properties'),
+ ('node', 'attributes'),
+ ('group', 'properties'),
+ ('policy', 'properties')
+)
+
+
+# Values
+
+NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
+NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
+NOT_A_STRING = ('123', '0.123', '[]', '{}')
+NOT_A_RANGE = NOT_A_LIST + (
+ '[]', '[ 1 ]', '[ 1, 2, 3 ]',
+ '[ 1, 1 ]', '[ 2, 1 ]',
+ '[ 1, a string ]', '[ a string, 1 ]',
+ '[ 1.5, 2 ]', '[ 1, 2.5 ]'
+)
+NOT_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]',)
GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'")
BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x')
STATUSES = ('supported', 'unsupported', 'experimental', 'deprecated')
+ENTRY_SCHEMA_VALUES = (
+ ('string', 'a string', 'another string'),
+ ('integer', '1', '2'),
+ ('float', '1.1', '2.2')
+)
+ENTRY_SCHEMA_VALUES_BAD = (
+ ('string', 'a string', '1'),
+ ('integer', '1', 'a string'),
+ ('float', '1.1', 'a string')
+)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
new file mode 100644
index 0000000..67731b3
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
@@ -0,0 +1,169 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+# Entry schema
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_map(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_map_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_list(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_list_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+# Required
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_property_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_failure()
+
+
+def test_node_type_property_not_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ required: false
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+def test_node_type_property_required_with_default(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ default: a string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
index 0177ef7..0087f96 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -37,7 +37,7 @@ node_types:
BAD_IMPORT = """
node_types:
MyNode:
- derived_from: not.a.node.type
+ derived_from: UnknownType
"""
@pytest.fixture(scope='session')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
deleted file mode 100644
index 185451e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
+++ /dev/null
@@ -1,413 +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 itertools
-
-import pytest
-
-from ... import data
-
-
-TYPE_NAMES = ('node', 'relationship', 'group')
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_interface_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {} # "type" is required
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs: {}
- operation1: {}
- operation2: {}
-""", dict(name=name)).assert_success()
-
-
-# Type
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override_good(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2: {}
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType1
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2: {}
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType2
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Interface inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input2:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_same(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_derived(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Operations
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- description: a description
- implementation: {}
- inputs: {}
-""", dict(name=name)).assert_success()
-
-
-# Operation implementation
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_short_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation: an implementation
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_long_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: an implementation
- dependencies:
- - a dependency
- - another dependency
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- implementation:
- primary: an implementation
- dependencies:
- - {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Operation inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input2:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_same_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_derived_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: MyType1
-""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
deleted file mode 100644
index 291abc8..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
+++ /dev/null
@@ -1,334 +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 itertools
-
-import pytest
-
-from ... import data
-
-
-SECTIONS = (
- ('artifact', 'properties'),
- ('data', 'properties'),
- ('capability', 'properties'),
- ('capability', 'attributes'),
- ('interface', 'inputs'),
- ('relationship', 'properties'),
- ('relationship', 'attributes'),
- ('node', 'properties'),
- ('node', 'attributes'),
- ('group', 'properties'),
- ('policy', 'properties')
-)
-SECTION_NAMES = ('properties', 'attributes')
-ENTRY_SCHEMA_VALUES = (
- ('string', 'a string', 'another string'),
- ('integer', '1', '2'),
- ('float', '1.1', '2.2')
-)
-ENTRY_SCHEMA_VALUES_BAD = (
- ('string', 'a string', '1'),
- ('integer', '1', 'a string'),
- ('float', '1.1', 'a string')
-)
-
-
-# Fields
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_fields(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- description: a description
- default: a value
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- 參數:
- type: string
- description: 描述
- default: 值
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-# Status
-
-@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(SECTIONS, data.STATUSES))
-)
-def test_node_type_parameter_status_good(parser, name, parameter_section, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: {{ value }}
-""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', SECTIONS)
-def test_node_type_parameter_status_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: not a status
-""", dict(name=name, parameter_section=parameter_section)).assert_failure()
-
-
-# Entry schema
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_map(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_map_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_list(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_list_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-# Required
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_property_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_failure()
-
-
-def test_node_type_property_not_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- required: false
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-def test_node_type_property_required_with_default(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- default: a string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-# Overriding
-
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_add_default(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: string
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: string
- default: my value
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_type_override(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: MyType1
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: MyType2
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_type_override_bad(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: MyType2
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: MyType1
-""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
deleted file mode 100644
index 53845c5..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
+++ /dev/null
@@ -1,152 +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 itertools
-
-import pytest
-
-from ... import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_derived_from_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Derivation
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_unknown(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: UnknownType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_null(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: null
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_self(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: MyType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_circular(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- derived_from: MyType3
- MyType2:
- derived_from: MyType1
- MyType3:
- derived_from: MyType2
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_root(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0
- description: a description
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0.詠嘆調-10
- description: 描述
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.BAD_VERSIONS
-))
-def test_type_bad_version(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- version: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
index 4b1c446..862772a 100644
--- 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
@@ -39,16 +39,6 @@ node_types:
""", dict(name=name, value=value)).assert_failure()
-@pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_node_type_requirements_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- requirements: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
@pytest.mark.parametrize('name', DICT_FIELD_NAMES)
def test_node_type_fields_empty(parser, name):
parser.parse_literal("""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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 0b1abf6..345fa49 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
@@ -14,14 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import itertools
+
import pytest
from ... import data
-
-SECTION_NAMES = ('properties', 'attributes')
-
-
# Syntax
@pytest.mark.parametrize('value', data.NOT_A_DICT)
@@ -92,7 +90,7 @@ node_types:
@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_capability_type_override_good(parser):
+def test_node_type_capability_type_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -134,50 +132,138 @@ node_types:
# Parameters
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_add(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_fields(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_fields_unicode(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+node_types:
+ 類型:
+ capabilities:
+ 能力:
+ type: 類型
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section,value', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.STATUSES
+))
+def test_node_type_capability_parameter_status(parser, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: {{ value }}
+""", dict(parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_status_bad(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: not a status
+""", dict(parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_add(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter1:
type: string
- description: a description
- default: a value
- status: supported
node_types:
MyType:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter2:
type: string
- description: a description
- default: a value
- status: supported
-""", dict(section=section)).assert_success()
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_add_default(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ default: my value
+""", dict(parameter_section=parameter_section)).assert_success()
@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_override(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_type_override(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
- MyType1:
- properties:
- field1:
- type: string
+ MyType1: {}
MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
+ derived_from: {}
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType1
node_types:
@@ -185,30 +271,23 @@ node_types:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType2
-""", dict(section=section)).assert_success()
+""", dict(parameter_section=parameter_section)).assert_success()
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_override_bad(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_type_override_bad(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
- MyType1:
- properties:
- field1:
- type: string
+ MyType1: {}
MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
+ derived_from: {}
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType2
node_types:
@@ -216,7 +295,101 @@ node_types:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType1
-""", dict(section=section)).assert_failure()
+""", dict(parameter_section=parameter_section)).assert_failure()
+
+
+# Valid source types
+
+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:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ MyType1, MyType2 ]
+ MyType2: {}
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_node_type_capability_valid_source_types_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ 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_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_valid_source_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: []
+""").assert_success()
+
+
+
+
+def test_node_type_capability_valid_source_types_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ UnknownType ]
+""").assert_failure()
+
+
+# Occurrences
+
+@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+def test_node_type_capability_occurrences(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
new file mode 100644
index 0000000..fb50bfa
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
@@ -0,0 +1,650 @@
+# -*- 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.
+
+"""
+Developer note: make sure that these tests mirror those in test_type_interfaces.py.
+"""
+
+import pytest
+
+from ... import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_relationship_interface_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_relationship_interface_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface: {} # "type" is required
+""").assert_failure()
+
+
+def test_node_type_relationship_interface_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ my_operation1: {}
+ my_operation2: {}
+""").assert_success()
+
+
+def test_node_type_relationship_interface_fields_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+relationship_types:
+ 類型: {}
+interface_types:
+ 類型: {}
+node_types:
+ 類型:
+ requirements:
+ - 需求:
+ capability: 類型
+ relationship:
+ type: 類型
+ interfaces:
+ 接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+""").assert_success()
+
+
+# Type
+
+def test_node_type_relationship_interface_type_override1(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType1
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+""").assert_success()
+
+
+def test_node_type_relationship_interface_type_override2(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_type_override1_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType2
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+""").assert_failure()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_type_override2_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+""").assert_failure()
+
+
+# Interface inputs
+
+def test_node_type_relationship_interface_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_inputs_type_override_same(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_inputs_type_override_derived(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_inputs_type_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
+
+
+# Operations
+
+def test_node_type_relationship_interface_operation_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation: {}
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ description: a description
+ implementation: {}
+ inputs: {}
+""").assert_success()
+
+
+# Operation implementation
+
+def test_node_type_relationship_interface_operation_implementation_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_implementation_long_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_relationship_interface_operation_implementation_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_relationship_interface_operation_dependencies_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# Operation inputs
+
+def test_node_type_relationship_interface_operation_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input2:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_inputs_override_same_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_inputs_override_derived_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_operation_inputs_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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 5ad866f..a43a994 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
@@ -14,10 +14,109 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import pytest
-# Overriding
+from ... import data
-def test_node_type_requirement_override_change_type_good(parser):
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_requirement_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: {} # "capability" is required
+""").assert_failure()
+
+
+def test_node_type_requirement_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType
+ relationship:
+ type: MyType
+ occurrences: [ 0, UNBOUNDED ]
+""").assert_success()
+
+
+def test_node_type_requirement_fields_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+relationship_types:
+ 類型: {}
+node_types:
+ 類型:
+ requirements:
+ - 需求:
+ capability: 類型
+ node: 類型
+ relationship:
+ type: 類型
+ occurrences: [ 0, UNBOUNDED ]
+""").assert_success()
+
+
+# Capability
+
+def test_node_type_requirement_capability_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: MyType
+""").assert_success()
+
+
+def test_node_type_requirement_capability_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_capability_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: null
+""").assert_failure()
+
+
+def test_node_type_requirement_capability_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -32,5 +131,131 @@ node_types:
derived_from: MyType1
requirements:
- my_requirement:
- capability: MyType2 # you should be allowed to change the capability type to anything
+ capability: MyType2 # you are allowed to change the capability type to anything
""").assert_success()
+
+
+# Node
+
+def test_node_type_requirement_node_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_node_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: null
+""").assert_failure()
+
+
+def test_node_type_requirement_node_override(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType3
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType4 # you are allowed to change the node type to anything
+ MyType3: {}
+ MyType4: {}
+""").assert_success()
+
+
+# Relationship
+
+def test_node_type_requirement_relationship_type_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_relationship_type_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: null
+""").assert_failure()
+
+
+def test_node_type_requirement_relationship_type_override(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType1: {}
+ MyType2: {}
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType2 # you are allowed to change the relationship type to anything
+""").assert_success()
+
+
+# Occurrences
+
+@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+def test_node_type_requirement_occurrences(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ type: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
new file mode 100644
index 0000000..da70b6b
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
@@ -0,0 +1,74 @@
+# -*- 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
+
+
+# Syntax
+
+def test_artifact_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)
+def test_artifact_mime_type_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ mime_type: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# File extension
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_artifact_file_ext_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_artifact_file_ext_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: []
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_artifact_file_ext_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
new file mode 100644
index 0000000..b35ea28
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
@@ -0,0 +1,83 @@
+# -*- 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
+
+
+# Valid source types
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_capability_type_valid_source_types_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_capability_type_valid_source_types_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_capability_type_valid_source_types_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: []
+""").assert_success()
+
+
+def test_capability_type_valid_source_types(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+ MyType2: {}
+capability_types:
+ MyType:
+ valid_source_types: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_capability_type_valid_source_types_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+capability_types:
+ 類型:
+ valid_source_types: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_capability_type_valid_source_types_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: [ UnknownType ]
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
new file mode 100644
index 0000000..b48e2dd
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
@@ -0,0 +1,83 @@
+# -*- 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
+
+
+# Members
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_group_type_members_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_group_type_members_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_group_type_members_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: []
+""").assert_success()
+
+
+def test_group_type_members(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+ MyType2: {}
+group_types:
+ MyType:
+ members: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_group_type_members_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+group_types:
+ 類型:
+ members: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_group_type_members_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: [ UnknownType ]
+""").assert_failure()
[08/10] incubator-ariatosca git commit: More tests.
Posted by em...@apache.org.
More tests.
* Make 'type' required in interface type
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/deb02b2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/deb02b2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/deb02b2d
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: deb02b2dacaef3cb39222b048d2aacf4c379c353
Parents: 9d1183a
Author: Tal Liron <ta...@gmail.com>
Authored: Fri Aug 25 17:10:15 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 10:40:50 2017 -0500
----------------------------------------------------------------------
.../simple_v1_0/definitions.py | 2 +-
.../simple_v1_0/modeling/parameters.py | 8 +-
.../simple_v1_0/presentation/types.py | 2 +-
.../simple_v1_0/conftest.py | 2 +
.../aria_extension_tosca/simple_v1_0/data.py | 1 +
.../simple_v1_0/templates/__init__.py | 14 +
.../simple_v1_0/templates/test_templates.py | 129 ++++++++
.../simple_v1_0/test_imports.py | 10 +-
.../simple_v1_0/test_templates.py | 129 --------
.../simple_v1_0/test_types.py | 153 ---------
.../simple_v1_0/types/__init__.py | 14 +
.../simple_v1_0/types/test_node_type.py | 68 ++++
.../types/test_node_type_capabilities.py | 72 +++++
.../types/test_node_type_interfaces.py | 72 +++++
.../types/test_node_type_requirements.py | 69 ++++
.../simple_v1_0/types/test_type_parameters.py | 318 +++++++++++++++++++
.../simple_v1_0/types/test_types.py | 152 +++++++++
17 files changed, 925 insertions(+), 290 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/extensions/aria_extension_tosca/simple_v1_0/definitions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/definitions.py b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
index 9158776..da08a07 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
@@ -283,7 +283,7 @@ class InterfaceDefinition(ExtensiblePresentation):
@field_validator(type_validator('interface type', convert_name_to_full_type_name,
'interface_types'))
- @primitive_field(str)
+ @primitive_field(str, required=True)
def type(self):
"""
ARIA NOTE: This field is not mentioned in the spec, but is implied.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
index f271b4d..5ba8d07 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
@@ -141,8 +141,8 @@ def validate_required_values(context, presentation, values, definitions):
for name, definition in definitions.iteritems():
if getattr(definition, 'required', False) \
and ((values is None) or (values.get(name) is None)):
- context.validation.report('required property "%s" is not assigned a value in "%s"'
- % (name, presentation._fullname),
+ context.validation.report('required property "{0}" is not assigned a value in "{1}"'
+ .format(name, presentation._fullname),
locator=presentation._get_child_locator('properties'),
level=Issue.BETWEEN_TYPES)
@@ -155,8 +155,8 @@ def merge_raw_parameter_definition(context, presentation, raw_property_definitio
type2 = our_property_definition.type
if type1 != type2:
context.validation.report(
- 'override changes type from "%s" to "%s" for property "%s" in "%s"'
- % (type1, type2, property_name, presentation._fullname),
+ 'override changes type from "{0}" to "{1}" for property "{2}" in "{3}"'
+ .format(type1, type2, property_name, presentation._fullname),
locator=presentation._get_child_locator(field_name, property_name),
level=Issue.BETWEEN_TYPES)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
index 920ebed..bf00c0d 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
@@ -36,7 +36,7 @@ def convert_name_to_full_type_name(context, name, types_dict): # pylint: disable
def get_type_by_name(context, name, *types_dict_names):
"""
- Gets a type either by its full name or its shorthand name or typequalified name.
+ Gets a type either by its full name or its shorthand name or type-qualified name.
Works by checking for ``shorthand_name`` in the types' ``_extensions`` field. See also
:class:`~aria_extension_tosca.v1_0.presentation.extensible.ExtensiblePresentation`.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
index 399e8c8..bd89b19 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/conftest.py
@@ -15,6 +15,8 @@
"""
PyTest configuration module.
+
+Add support for a "--tosca-parser" CLI option.
"""
import pytest
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
index b24fb29..1edb5e3 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -38,3 +38,4 @@ TEMPLATE_NAME_SECTION = {
}
GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'")
BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x')
+STATUSES = ('supported', 'unsupported', 'experimental', 'deprecated')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/templates/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py
new file mode 100644
index 0000000..98f06ca
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py
@@ -0,0 +1,129 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_topology_template_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_topology_template_emtpy(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template: {}
+""").assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_DICT
+))
+def test_template_section_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: tosca.{{ plural }}.Root
+ description: a description
+""", dict(section=data.TEMPLATE_NAME_SECTION[name],
+ plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Of types
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_type_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型: {}
+topology_template:
+ {{ section }}:
+ 模板:
+ type: 類型
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_unknown_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: UnknownType
+""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_of_null_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: null
+""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
index 765cd8b..4d8af8b 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -28,6 +28,12 @@ node_types:
derived_from: tosca.nodes.Root
"""
+NODE_TYPE_IMPORT_UNICODE = """
+node_types:
+ 類型:
+ derived_from: tosca.nodes.Root
+"""
+
BAD_IMPORT = """
node_types:
MyNode:
@@ -39,7 +45,7 @@ def repository():
repository = WebServer()
repository.add_text_yaml('/imports/node-type.yaml', NODE_TYPE_IMPORT)
repository.add_text_yaml('/imports/{0}.yaml'.format(WebServer.escape('節點類型')),
- NODE_TYPE_IMPORT)
+ NODE_TYPE_IMPORT_UNICODE)
repository.add_text_yaml('/imports/bad.yaml', BAD_IMPORT)
with repository:
yield repository.root
@@ -84,7 +90,7 @@ imports:
topology_template:
node_templates:
my_node:
- type: MyNode
+ type: 類型
""", dict(repository=repository)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
deleted file mode 100644
index 8b0fd0e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_templates.py
+++ /dev/null
@@ -1,129 +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 itertools
-
-import pytest
-
-from . import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('value', data.NOT_A_DICT)
-def test_topology_template_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
-def test_topology_template_emtpy(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template: {}
-""").assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_NAMES,
- data.NOT_A_DICT
-))
-def test_template_section_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}: {{ value }}
-""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_NAMES,
- data.NOT_A_STRING
-))
-def test_template_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: {{ value }}
-""", dict(section=data.TEMPLATE_NAME_SECTION[name], value=value)).assert_failure()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: tosca.{{ plural }}.Root
- description: a description
-""", dict(section=data.TEMPLATE_NAME_SECTION[name],
- plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-# Of types
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_type_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型: {}
-topology_template:
- {{ section }}:
- 模板:
- type: 類型
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTION[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_unknown_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: UnknownType
-""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_null_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: null
-""", dict(section=data.TEMPLATE_NAME_SECTION[name])).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
deleted file mode 100644
index 0699e1e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_types.py
+++ /dev/null
@@ -1,153 +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 itertools
-
-import pytest
-
-from . import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_derived_from_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-
-# Derivation
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_unknown(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: UnknownType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_null(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: null
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_self(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: MyType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_circular(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- derived_from: MyType3
- MyType2:
- derived_from: MyType1
- MyType3:
- derived_from: MyType2
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_root(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0
- description: a description
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0.詠嘆調-10
- description: 描述
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.BAD_VERSIONS
-))
-def test_type_bad_version(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- version: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
new file mode 100644
index 0000000..b2767c1
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type.py
@@ -0,0 +1,68 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+DICT_FIELD_NAMES = ('properties', 'attributes', 'capabilities', 'interfaces', 'artifacts')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ DICT_FIELD_NAMES,
+ data.NOT_A_DICT
+))
+def test_node_type_fields_wrong_yaml_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('value', data.NOT_A_LIST)
+def test_node_type_requirements_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', DICT_FIELD_NAMES)
+def test_node_type_fields_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_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/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
new file mode 100644
index 0000000..fa9af73
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_capabilities.py
@@ -0,0 +1,72 @@
+# -*- 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
+
+
+# Overriding
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_capability_override_change_type_good(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1:
+ properties:
+ prop1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ prop2:
+ type: integer
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ capabilities:
+ my_capability:
+ type: MyType2
+""").assert_success()
+
+
+def test_node_type_capability_override_change_type_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1:
+ properties:
+ prop1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ prop2:
+ type: integer
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ capabilities:
+ my_capability:
+ type: MyType1
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
new file mode 100644
index 0000000..0228c02
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_interfaces.py
@@ -0,0 +1,72 @@
+# -*- 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
+
+
+# Overriding
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_interface_override_change_type_good(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ inputs:
+ input1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ input2:
+ type: integer
+node_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType2
+""").assert_success()
+
+
+def test_node_type_interface_override_change_type_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ inputs:
+ input1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ input2:
+ type: integer
+node_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType1
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
new file mode 100644
index 0000000..b823cd4
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_node_type_requirements.py
@@ -0,0 +1,69 @@
+# -*- 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.
+
+
+# Overriding
+
+def test_node_type_requirement_override_change_type_good1(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1:
+ properties:
+ prop1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ prop2:
+ type: integer
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType2
+""").assert_success()
+
+
+def test_node_type_requirement_override_change_type_good2(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType1:
+ properties:
+ prop1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ prop2:
+ type: integer
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType2
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType1 # you should be allowed to change the capability type to anything
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
new file mode 100644
index 0000000..be5ad43
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
@@ -0,0 +1,318 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+SECTIONS = (
+ ('artifact', 'properties'),
+ ('data', 'properties'),
+ ('capability', 'properties'),
+ ('capability', 'attributes'),
+ ('relationship', 'properties'),
+ ('relationship', 'attributes'),
+ ('node', 'properties'),
+ ('node', 'attributes'),
+ ('group', 'properties'),
+ ('policy', 'properties')
+)
+SECTION_NAMES = ('properties', 'attributes')
+ENTRY_SCHEMA_VALUES = (
+ ('string', 'a string', 'another string'),
+ ('integer', '1', '2'),
+ ('float', '1.1', '2.2')
+)
+ENTRY_SCHEMA_VALUES_BAD = (
+ ('string', 'a string', '1'),
+ ('integer', '1', 'a string'),
+ ('float', '1.1', 'a string')
+)
+
+
+# Fields
+
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_fields(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_param:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Status
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(SECTIONS, data.STATUSES))
+)
+def test_node_type_parameter_status_good(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_param:
+ type: string
+ status: {{ value }}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', SECTIONS)
+def test_node_type_parameter_status_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_param:
+ type: string
+ status: bad
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Entry schema
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_map(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_param:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_param:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_map_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_param:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_param:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_list(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_param:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_param:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ SECTION_NAMES,
+ ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_list_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_param:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_param:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+# Required
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_property_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_failure()
+
+
+def test_node_type_property_not_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ required: false
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+def test_node_type_property_required_with_default(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ default: a string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+# Overriding
+
+@pytest.mark.parametrize('section', SECTION_NAMES)
+def test_node_type_parameter_override_add_default(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1:
+ {{ section }}:
+ my_param:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_param:
+ type: string
+ default: my value
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('section', ('properties', 'attributes'))
+def test_node_type_parameter_override_change_type_good(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+node_types:
+ MyType1:
+ {{ section }}:
+ my_param:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_param:
+ type: MyType2
+""", dict(section=section)).assert_success()
+
+
+@pytest.mark.parametrize('section', ('properties', 'attributes'))
+def test_node_type_parameter_override_change_type_bad(parser, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1:
+ properties:
+ field1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ properties:
+ field2:
+ type: integer
+node_types:
+ MyType1:
+ {{ section }}:
+ my_param:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ {{ section }}:
+ my_param:
+ type: MyType1
+""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/deb02b2d/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
new file mode 100644
index 0000000..8e2f26f
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
@@ -0,0 +1,152 @@
+# -*- 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 itertools
+
+import pytest
+
+from .. import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Derivation
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: UnknownType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_null(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: null
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_self(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: MyType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_circular(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ derived_from: MyType3
+ MyType2:
+ derived_from: MyType1
+ MyType3:
+ derived_from: MyType2
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_root(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0
+ description: a description
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ derived_from: tosca.{{ plural }}.Root
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.BAD_VERSIONS
+))
+def test_type_bad_version(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_failure()