ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject [09/10] incubator-ariatosca git commit: Most type tests complete
Date Wed, 30 Aug 2017 22:13:25 GMT
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()


Mime
View raw message