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/10/31 19:34:01 UTC
[06/13] incubator-ariatosca git commit: ARIA-1 Parser test suite
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/test_names.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_names.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_names.py
new file mode 100644
index 0000000..54cfd90
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_names.py
@@ -0,0 +1,57 @@
+# -*- 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.
+
+
+def test_names_shorthand(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ node_templates:
+ my_server:
+ type: Compute
+ requirements:
+ - local_storage:
+ node: my_block_storage
+ relationship:
+ type: AttachesTo
+ properties:
+ location: /path1/path2
+ my_block_storage:
+ type: BlockStorage
+ properties:
+ size: 10 GB
+""", import_profile=True).assert_success()
+
+
+def test_names_type_qualified(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ node_templates:
+ my_server:
+ type: tosca:Compute
+ requirements:
+ - local_storage:
+ node: my_block_storage
+ relationship:
+ type: AttachesTo
+ properties:
+ location: /path1/path2
+ my_block_storage:
+ type: tosca:BlockStorage
+ properties:
+ size: 10 GB
+""", import_profile=True).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/test_profile.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_profile.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_profile.py
new file mode 100644
index 0000000..922f9dc
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_profile.py
@@ -0,0 +1,20 @@
+# 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.
+
+
+def test_profile(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+""", import_profile=True, validate_normative=True).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/test_repositories.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_repositories.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_repositories.py
new file mode 100644
index 0000000..9d40e22
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_repositories.py
@@ -0,0 +1,179 @@
+# -*- 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
+
+
+# Repositories section
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_repositories_section_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_repositories_section_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories: {}
+""").assert_success()
+
+
+# Repository
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_repository_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_repository_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ unsupported: {}
+""").assert_failure()
+
+
+def test_repository_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository: {} # "url" is required
+""").assert_failure()
+
+
+# Description
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_repository_description_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ description: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_repository_description(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ description: a description
+""").assert_success()
+
+
+# URL
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_repository_url_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_repository_url_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository: a url
+""").assert_success()
+
+
+# Credential
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_repository_credential_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ credential: {{ value }}
+""", dict(value=value), import_profile=True).assert_failure()
+
+
+def test_repository_credential_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ credential:
+ unsupported: {}
+""", import_profile=True).assert_failure()
+
+
+def test_repository_credential_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ credential: {}
+""", import_profile=True).assert_success()
+
+
+def test_repository_credential_full(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ my_repository:
+ url: a url
+ credential:
+ protocol: a protocol
+ token_type: a token type
+ token: a token
+ keys:
+ key1: value1
+ key2: value2
+ user: a user
+""", import_profile=True).assert_success()
+
+
+# Unicode
+
+def test_repository_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+repositories:
+ 知識庫:
+ url: 網址
+ description: 描述
+ credential:
+ protocol: 協議
+ token_type: 類型
+ token: 代幣
+ keys:
+ 鍵一: 值
+ 鍵二: 值
+ user: 用戶
+""", import_profile=True).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/test_service_template.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_service_template.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_service_template.py
new file mode 100644
index 0000000..2bcd018
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_service_template.py
@@ -0,0 +1,22 @@
+# -*- 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.
+
+
+def test_service_template_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+unsupported: {}
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/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/b89fdde2/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/b89fdde2/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..6343442
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
@@ -0,0 +1,469 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+from ... import data
+from ......mechanisms.utils import matrix
+
+
+# Interfaces defined at a type
+MAIN_MACROS = """
+{% macro additions() %}
+{%- endmacro %}
+{% macro interfaces() %}
+ interfaces: {{ caller()|indent(6) }}
+{%- endmacro %}
+"""
+
+# Interfaces defined (added/overridden) at a relationship of a requirement within a node type
+RELATIONSHIP_MACROS = """
+{% macro additions() %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+{%- endmacro %}
+{% macro interfaces() %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces: {{ caller()|indent(14) }}
+{%- endmacro %}
+"""
+
+MACROS = {
+ 'main': MAIN_MACROS,
+ 'relationship': RELATIONSHIP_MACROS
+}
+
+PERMUTATIONS = (
+ ('main', 'node'),
+ ('main', 'group'),
+ ('main', 'relationship'),
+ ('relationship', 'node')
+)
+
+PERMUTATIONS_NO_RELATIONSHIP = tuple(
+ (macros, name)
+ for macros, name in PERMUTATIONS
+ if macros != 'relationship'
+)
+
+
+# Interfaces section
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_DICT,
+ counts=(2, 1)
+))
+def test_type_interfaces_section_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() -%}
+{{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interfaces_section_syntax_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() -%}
+{}
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+# Interface
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_DICT,
+ counts=(2, 1)
+))
+def test_type_interface_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_syntax_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface: {} # "type" is required
+{% endcall %}
+""", dict(name=name)).assert_failure()
+
+
+# Type
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_type_override(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+{{ name }}_types:
+ MyType1:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType1
+{% endcall %}
+ MyType2:
+ derived_from: MyType1
+{%- call interfaces() %}
+MyInterface:
+ type: MyType2
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+# We are skipping relationship interfaces, because node requirements can be overridden completely
+@pytest.mark.parametrize('macros,name', PERMUTATIONS_NO_RELATIONSHIP)
+def test_type_interface_type_override_bad(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType1: {}
+ MyType2: {}
+{{ name }}_types:
+ MyType1:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType1
+{% endcall %}
+ MyType2:
+ derived_from: MyType1
+{%- call interfaces() %}
+MyInterface:
+ type: MyType2
+{% endcall %}
+""", dict(name=name)).assert_failure()
+
+
+# Operation
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_DICT_OR_STRING,
+ counts=(2, 1)
+))
+def test_type_interface_operation_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_syntax_unsupported(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ unsupported: {}
+{% endcall %}
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_syntax_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation: {}
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+# Operation description
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_STRING,
+ counts=(2, 1)
+))
+def test_type_interface_operation_description_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ description: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_description(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ description: a description
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_DICT_OR_STRING,
+ counts=(2, 1)
+))
+def test_type_interface_operation_implementation_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_implementation_syntax_unsupported(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation:
+ unsupported: {}
+{% endcall %}
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_implementation_syntax_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation: {}
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_STRING,
+ counts=(2, 1)
+))
+def test_type_interface_operation_implementation_primary_syntax_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_implementation_primary_short_form(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_LIST,
+ counts=(2, 1)
+))
+def test_type_interface_operation_implementation_dependencies_syntax_type(parser, macros, name,
+ value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies: {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,value', matrix(
+ PERMUTATIONS, data.NOT_A_STRING,
+ counts=(2, 1)
+))
+def test_type_interface_operation_implementation_dependencies_syntax_element_type(parser, macros,
+ name, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_operation_implementation_dependencies_syntax_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+{%- call interfaces() %}
+MyInterface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies: []
+{% endcall %}
+""", dict(name=name)).assert_success()
+
+
+# Unicode
+
+@pytest.mark.parametrize('macros,name', PERMUTATIONS)
+def test_type_interface_unicode(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+interface_types:
+ 類型: {}
+{{ name }}_types:
+ 類型:
+{%- call interfaces() %}
+接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+{% endcall %}
+""", dict(name=name)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/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..3cbf47c
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
@@ -0,0 +1,418 @@
+# -*- 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.
+
+"""
+Unified testing for properties, attributes, and inputs.
+
+Additional tests for properties are in test_type_properties.py.
+
+Note: artifact definitions within node types use parameter assignments rather than definitions, and
+thus are tested not here but under test_template_parameters.py.
+"""
+
+import pytest
+
+from ... import data
+from ......mechanisms.utils import matrix
+
+
+# Defining parameters at a type
+MAIN_MACROS = """
+{% macro additions(section=True) %}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ {{ parameter_section }}: {{ caller()|indent(6) }}
+{%- endmacro %}
+"""
+
+# Defining parameters at a nested type (e.g. inputs of an operation within an interface type)
+NESTED_MACROS = """
+{% macro additions(section=True) %}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ nested:
+ {{ parameter_section }}: {{ caller()|indent(8) }}
+{%- endmacro %}
+"""
+
+# Defining inputs at an interface of a type
+INTERFACE_MACROS = """
+{% macro additions(section=True) %}
+interface_types:
+ MyType: {}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ interfaces:
+ my_interface:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(10) }}
+{%- endmacro %}
+"""
+
+# Defining inputs at an operation of an interface of a type
+OPERATION_MACROS = """
+{% macro additions(section=True) %}
+interface_types:
+ MyType: {}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ {{ parameter_section }}: {{ caller()|indent(12) }}
+{%- endmacro %}
+"""
+
+# Defining inputs at an interface of a relationship of a requirement of a node type
+RELATIONSHIP_INTERFACE_MACROS = """
+{% macro additions(section=True) %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(18) }}
+{%- endmacro %}
+"""
+
+# Defining inputs at an operation of an interface of a relationship of a requirement of a node type
+RELATIONSHIP_OPERATION_MACROS = """
+{% macro additions(section=True) %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ {{ parameter_section }}: {{ caller()|indent(20) }}
+{%- endmacro %}
+"""
+
+# Defining parameters at a capability of a node type
+CAPABILITY_MACROS = """
+{% macro additions(section=True) %}
+capability_types:
+ MyType: {}
+{%- if section %}
+{{ name }}_types:
+{%- endif %}
+{%- endmacro %}
+{% macro parameters(t='MyType', d=None) %}
+ {{ t }}:
+{%- if d %}
+ derived_from: {{ d }}
+{%- endif %}
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(10) }}
+{%- endmacro %}
+"""
+
+# Defining inputs/outputs at a topology template
+TOPOLOGY_MACROS = """
+{% macro additions(section=None) %}
+topology_template:
+{%- endmacro %}
+{% macro parameters(t=None) %}
+ {{ parameter_section }}: {{ caller()|indent(4) }}
+{%- endmacro %}
+"""
+
+
+MACROS = {
+ 'main': MAIN_MACROS,
+ 'nested': NESTED_MACROS,
+ 'interface': INTERFACE_MACROS,
+ 'operation': OPERATION_MACROS,
+ 'relationship-interface': RELATIONSHIP_INTERFACE_MACROS,
+ 'relationship-operation': RELATIONSHIP_OPERATION_MACROS,
+ 'capability': CAPABILITY_MACROS,
+ 'topology': TOPOLOGY_MACROS
+}
+
+PERMUTATIONS_TYPE_REQUIRED = (
+ ('main', 'node', 'properties'),
+ ('main', 'node', 'attributes'),
+ ('main', 'group', 'properties'),
+ ('main', 'relationship', 'properties'),
+ ('main', 'relationship', 'attributes'),
+ ('main', 'capability', 'properties'),
+ ('main', 'capability', 'attributes'),
+ ('main', 'policy', 'properties'),
+ ('main', 'interface', 'inputs'),
+ ('main', 'artifact', 'properties'),
+ ('main', 'data', 'properties'),
+ ('nested', 'interface', 'inputs'),
+ ('interface', 'node', 'inputs'),
+ ('interface', 'group', 'inputs'),
+ ('interface', 'relationship', 'inputs'),
+ ('operation', 'node', 'inputs'),
+ ('operation', 'group', 'inputs'),
+ ('operation', 'relationship', 'inputs'),
+ ('relationship-interface', 'node', 'inputs'),
+ ('relationship-operation', 'node', 'inputs'),
+ ('capability', 'node', 'properties'),
+ ('capability', 'node', 'attributes'),
+ ('topology', None, 'inputs')
+)
+
+PERMUTATIONS = PERMUTATIONS_TYPE_REQUIRED + (
+ ('topology', None, 'outputs'),
+)
+
+
+# Parameters section
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_DICT,
+ counts=(3, 1)
+))
+def test_type_parameters_section_syntax_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() -%}
+{{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameters_section_syntax_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() -%}
+{}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Parameter
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_DICT,
+ counts=(3, 1)
+))
+def test_type_parameter_syntax_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS_TYPE_REQUIRED)
+def test_type_parameter_syntax_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter: {} # type is required
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_syntax_unsupported(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ unsupported: {}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Description
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_STRING,
+ counts=(3, 1)
+))
+def test_type_parameter_description_syntax_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ description: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_description(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ description: a description
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Default
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_default(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ default: a string
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_default_bad(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: integer
+ default: a string
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Status
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.STATUSES,
+ counts=(3, 1)
+))
+def test_type_parameter_status(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ status: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_status_bad(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ status: not a status
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Unicode
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_unicode(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters('類型') %}
+參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py
new file mode 100644
index 0000000..49a57f6
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py
@@ -0,0 +1,114 @@
+# -*- 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.
+
+"""
+Unified testing for properties and inputs.
+
+These tests are in addition to the common tests for parameters in test_type_parameters.py.
+
+Compare with test_node_template_node_filter_constraints.py. Note that though the constraints are the
+same, their syntax is very different, making it difficult to test all permutations together.
+"""
+
+import pytest
+
+from .test_type_parameters import (MACROS, PERMUTATIONS as PARAMETER_PERMUTATIONS)
+
+
+PERMUTATIONS = tuple(
+ (macros, name, parameter_section)
+ for macros, name, parameter_section in PARAMETER_PERMUTATIONS
+ if name is not None
+)
+
+PERMUTATIONS_NO_RELATIONSHIP = tuple(
+ (macros, name, parameter_section)
+ for macros, name, parameter_section in PERMUTATIONS
+ if macros not in ('relationship-interface', 'relationship-operation')
+)
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_add(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters('MyType1') %}
+my_parameter1:
+ type: string
+{% endcall %}
+{%- call parameters('MyType2', 'MyType1') %}
+my_parameter2:
+ type: string
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_add_default(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters('MyType1') %}
+my_parameter:
+ type: string
+{% endcall %}
+{%- call parameters('MyType2', 'MyType1') %}
+my_parameter:
+ type: string
+ default: my value
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_type_override(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType1: {}
+ MyDataType2:
+ derived_from: MyDataType1
+{{- additions(name != 'data') }}
+{%- call parameters('MyType1') %}
+my_parameter:
+ type: MyDataType1
+{% endcall %}
+{%- call parameters('MyType2', 'MyType1') %}
+my_parameter:
+ type: MyDataType2
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# We are skipping relationship interfaces, because node requirements can be overridden completely
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS_NO_RELATIONSHIP)
+def test_type_parameter_type_override_bad(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType1: {}
+ MyDataType2: {}
+{{- additions(name != 'data') }}
+{%- call parameters('MyType1') %}
+my_parameter:
+ type: MyDataType1
+{% endcall %}
+{%- call parameters('MyType2', 'MyType1') %}
+my_parameter:
+ type: MyDataType2
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_properties.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_properties.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_properties.py
new file mode 100644
index 0000000..16fc875
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_properties.py
@@ -0,0 +1,312 @@
+# -*- 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.
+
+"""
+Unified testing for properties and inputs.
+
+These tests are in addition to the common tests for parameters in test_type_parameters.py.
+
+Compare with test_node_template_node_filter_constraints.py. Note that though the constraints are the
+same, their syntax is very different, making it difficult to test all permutations together.
+"""
+
+import pytest
+
+from .test_type_parameters import (MACROS, PERMUTATIONS as PARAMETER_PERMUTATIONS)
+from ... import data
+from ......mechanisms.utils import matrix
+
+
+PERMUTATIONS = tuple(
+ (macros, name, parameter_section)
+ for macros, name, parameter_section in PARAMETER_PERMUTATIONS
+ if parameter_section != 'attributes'
+)
+
+
+# Required
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_BOOL,
+ counts=(3, 1)
+))
+def test_type_parameter_required_syntax_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ required: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_required(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ required: true
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Constraints
+
+@pytest.mark.parametrize('macros,name,parameter_section,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_LIST,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_syntax_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_constraints_syntax_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints: []
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value(parser, macros, name, parameter_section, constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{{- additions(name != 'data') }}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}: {my_field: a string}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_LIST,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_list(parser, macros, name, parameter_section,
+ constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{{- additions(name != 'data') }}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string one}
+ - {my_field: string two}
+ - {my_field: string three}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_range(parser, macros, name, parameter_section,
+ constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{{- additions(name != 'data') }}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string a}
+ - {my_field: string b}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_range_too_many(parser, macros, name,
+ parameter_section, constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{{- additions(name != 'data') }}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string a}
+ - {my_field: string b}
+ - {my_field: string c}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_range_bad(macros, parser, name, parameter_section,
+ constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{{- additions(name != 'data') }}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string b}
+ - {my_field: string a}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_constraints_pattern(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - pattern: ^pattern$
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_constraints_pattern_bad(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - pattern: (
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_integer(parser, macros, name, parameter_section,
+ constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: 1
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
+ PERMUTATIONS,
+ data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT,
+ counts=(3, 1)
+))
+def test_type_parameter_constraints_with_value_integer_bad(parser, macros, name, parameter_section,
+ constraint):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: -1
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+# Unicode
+
+@pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS)
+def test_type_parameter_constraints_pattern_unicode(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+{%- call parameters('類型') %}
+參數:
+ type: string
+ constraints:
+ - pattern: ^模式$
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/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..a175498
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
@@ -0,0 +1,185 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+from ... import data
+from ......mechanisms.utils import matrix
+
+
+CASES_WITHOUT_UNSUPPORTED_FIELDS = ('artifact', 'data', 'capability', 'relationship', 'node',
+ 'group', 'policy')
+
+PERMUTATIONS = CASES_WITHOUT_UNSUPPORTED_FIELDS + ('interface',)
+
+
+@pytest.mark.parametrize('name,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_DICT
+))
+def test_type_syntax_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', CASES_WITHOUT_UNSUPPORTED_FIELDS)
+def test_type_syntax_unsupported(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ unsupported: {}
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', PERMUTATIONS)
+def test_type_syntax_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+# Description
+
+@pytest.mark.parametrize('name,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_STRING
+))
+def test_type_description_syntax_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ description: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', PERMUTATIONS)
+def test_type_description(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ description: a description
+""", dict(name=name)).assert_success()
+
+
+# Derived from
+
+@pytest.mark.parametrize('name,value', matrix(
+ PERMUTATIONS,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_syntax_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()
+
+
+@pytest.mark.parametrize('name', PERMUTATIONS)
+def test_type_derived_from(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', PERMUTATIONS)
+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', PERMUTATIONS)
+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', PERMUTATIONS)
+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()
+
+
+# Version
+
+@pytest.mark.parametrize('name,value', matrix(
+ PERMUTATIONS,
+ data.GOOD_VERSIONS
+))
+def test_type_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_success()
+
+
+@pytest.mark.parametrize('name,value', matrix(
+ PERMUTATIONS,
+ data.BAD_VERSIONS
+))
+def test_type_version_bad(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()
+
+
+# Unicode
+
+@pytest.mark.parametrize('name', PERMUTATIONS)
+def test_type_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型一: {}
+ 類型二:
+ derived_from: 類型一
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/__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/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py
new file mode 100644
index 0000000..5904a89
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py
@@ -0,0 +1,302 @@
+# -*- 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
+
+
+# Capabilities section
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_capabilities_section_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capabilities_section_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities: {}
+""").assert_success()
+
+
+# Capability
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_capability_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities:
+ my_capability: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ unsupported: {}
+""").assert_failure()
+
+
+def test_node_type_capability_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities:
+ my_capability: {} # "type" is required
+""").assert_failure()
+
+
+# Description
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_capability_description_syntax_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
+ description: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_description(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
+""").assert_success()
+
+
+# Type
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_capability_type_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+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_override(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: {}
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ capabilities:
+ my_capability:
+ type: MyType2
+""").assert_failure()
+
+
+# Valid source types
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_node_type_capability_valid_source_types_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ 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_syntax_element_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_types_syntax_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(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()
+
+
+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.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_success()
+
+
+@pytest.mark.parametrize('value', data.BAD_OCCURRENCES)
+def test_node_type_capability_occurrences_bad(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()
+
+
+# Unicode
+
+def test_node_type_capability_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+node_types:
+ 類型:
+ capabilities:
+ 能力:
+ type: 類型
+ properties:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+ valid_source_types: [ 類型 ]
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py
new file mode 100644
index 0000000..257fab1
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py
@@ -0,0 +1,54 @@
+# -*- 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.
+
+"""
+These tests are in addition to those in common/test_type_interface.py.
+"""
+
+
+# Type
+
+def test_node_type_relationship_interface_type_override(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType1: {}
+ MyType2: {}
+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 # overriding the requirement has no restrictions
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_requirements.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_requirements.py
new file mode 100644
index 0000000..22917e4
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_requirements.py
@@ -0,0 +1,361 @@
+# -*- 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
+
+
+# Requirements section
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_node_type_requirements_section_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirements_section_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements: []
+""").assert_success()
+
+
+# Requirement
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_requirement_syntax_type(parser, value):
+ 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_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ unsupported: {}
+""").assert_failure()
+
+
+def test_node_type_requirement_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: {} # "capability" is required
+""").assert_failure()
+
+
+# Capability
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_node_type_requirement_capability_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_capability_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability:
+ unsupported: {}
+""").assert_failure()
+
+
+# Capability type
+
+def test_node_type_requirement_capability_type_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_type_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_type_override(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 are allowed to change the capability type to anything
+""").assert_success()
+
+
+# Node
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_requirement_node_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+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_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
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_node_type_requirement_relationship_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_relationship_syntax_unsupported(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ unsupported: {}
+""").assert_failure()
+
+
+# Relationship type
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_node_type_requirement_relationship_type_syntax_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_relationship_type_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_relationship_type_short_form(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: MyType
+""").assert_success()
+
+
+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.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:
+ capability: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_success()
+
+
+@pytest.mark.parametrize('value', data.BAD_OCCURRENCES)
+def test_node_type_requirement_occurrences_bad(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# Unicode
+
+def test_node_type_requirement_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()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/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..d269a44
--- /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
+
+
+# MIME type
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_artifact_type_mime_type_syntax_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_type_file_ext_syntax_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()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_artifact_type_file_ext_syntax_element_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_artifact_type_file_ext_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: []
+""").assert_success()
+
+
+# Unicode
+
+
+def test_artifact_type_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ 類型:
+ file_ext: [ 延期一, 延期二 ]
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b89fdde2/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..217f163
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
@@ -0,0 +1,85 @@
+# -*- 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_syntax_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_syntax_element_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_syntax_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_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: [ UnknownType ]
+""").assert_failure()
+
+
+# Unicode
+
+def test_capability_type_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+capability_types:
+ 類型:
+ valid_source_types: [ 類型一, 類型二 ]
+""").assert_success()