Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-1-parser-test-suite 1d8ac549b -> 354328e94


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/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
index 134bbce..217f163 100644
--- 
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
@@ -22,7 +22,7 @@ from .. import data
 # Valid source types
 
 @pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_capability_type_valid_source_types_wrong_yaml_type(parser, value):
+def test_capability_type_valid_source_types_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 capability_types:
@@ -32,7 +32,7 @@ capability_types:
 
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_capability_type_valid_source_types_element_wrong_yaml_type(parser, 
value):
+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:
@@ -41,7 +41,7 @@ capability_types:
 """, dict(value=value)).assert_failure()
 
 
-def test_capability_type_valid_source_types_empty(parser):
+def test_capability_type_valid_source_types_syntax_empty(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 capability_types:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
index 539d4f8..5c0dd70 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
@@ -14,11 +14,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import itertools
-
 import pytest
 
 from .. import data
+from .....mechanisms.utils import matrix
 
 
 # Derived from primitive
@@ -35,11 +34,11 @@ data_types:
 
 # Constraints
 
[email protected]('name,value', itertools.product(
[email protected]('name,value', matrix(
     data.PRIMITIVE_TYPE_NAMES,
     data.NOT_A_LIST
 ))
-def test_data_type_constraints_wrong_yaml_type(parser, name, value):
+def test_data_type_constraints_syntax_type(parser, name, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 data_types:
@@ -50,7 +49,7 @@ data_types:
 
 
 @pytest.mark.parametrize('name', data.PRIMITIVE_TYPE_NAMES)
-def test_data_type_constraints_empty(parser, name):
+def test_data_type_constraints_syntax_empty(parser, name):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 data_types:
@@ -60,10 +59,10 @@ data_types:
 """, dict(name=name)).assert_success()
 
 
-def test_data_type_constraints_not_primitive(parser):
+def test_data_type_constraints_not_derived_from_primitive(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 data_types:
   MyType:
-    constraints: [] # can't have constraints if not a primitive
+    constraints: [] # can't have constraints if not derived from primitive
 """).assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
index 9d11d68..7816484 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
@@ -22,7 +22,7 @@ from .. import data
 # Members
 
 @pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_group_type_members_wrong_yaml_type(parser, value):
+def test_group_type_members_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 group_types:
@@ -32,7 +32,7 @@ group_types:
 
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_group_type_members_element_wrong_yaml_type(parser, value):
+def test_group_type_members_syntax_element_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 group_types:
@@ -41,7 +41,7 @@ group_types:
 """, dict(value=value)).assert_failure()
 
 
-def test_group_type_members_empty(parser):
+def test_group_type_members_syntax_empty(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 group_types:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
index c185fa0..d296930 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
@@ -21,7 +21,7 @@ from .. import data
 
 # Operations
 
-def test_interface_type_operation_empty(parser):
+def test_interface_type_operation_syntax_empty(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 interface_types:
@@ -33,7 +33,7 @@ interface_types:
 # Operation description
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_interface_type_operation_description_wrong_yaml_type(parser, value):
+def test_interface_type_operation_description_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 interface_types:
@@ -80,7 +80,7 @@ interface_types:
 
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_interface_type_operation_implementation_wrong_yaml_type(parser, 
value):
+def test_interface_type_operation_implementation_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 interface_types:
@@ -91,8 +91,21 @@ interface_types:
 """, dict(value=value)).assert_failure()
 
 
[email protected]('value', data.NOT_A_LIST)
+def test_interface_type_operation_dependencies_syntax_type(parser, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+  MyType:
+    my_operation:
+      implementation:
+        primary: an implementation
+        dependencies: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_interface_type_operation_dependencies_wrong_yaml_type(parser, value):
+def test_interface_type_operation_dependencies_element_syntax_type(parser, 
value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 interface_types:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/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
index 0f73a19..0f87741 100644
--- 
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
@@ -22,7 +22,7 @@ from .. import data
 # Targets
 
 @pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_policy_type_targets_wrong_yaml_type(parser, value):
+def test_policy_type_targets_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 policy_types:
@@ -32,7 +32,7 @@ policy_types:
 
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_policy_type_targets_element_wrong_yaml_type(parser, value):
+def test_policy_type_targets_syntax_element_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 policy_types:
@@ -41,7 +41,7 @@ policy_types:
 """, dict(value=value)).assert_failure()
 
 
-def test_policy_type_targets_empty(parser):
+def test_policy_type_targets_syntax_empty(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 policy_types:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/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
index b35406d..495e325 100644
--- 
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
@@ -22,7 +22,7 @@ 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):
+def test_relationship_type_valid_target_types_syntax_type(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 relationship_types:
@@ -32,7 +32,7 @@ relationship_types:
 
 
 @pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_relationship_type_valid_target_types_element_wrong_yaml_type(parser, 
value):
+def test_relationship_type_valid_target_types_syntax_element_type(parser, 
value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 relationship_types:
@@ -41,7 +41,7 @@ relationship_types:
 """, dict(value=value)).assert_failure()
 
 
-def test_relationship_type_valid_target_types_empty(parser):
+def test_relationship_type_valid_target_types_syntax_empty(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 relationship_types:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/354328e9/tests/mechanisms/utils.py
----------------------------------------------------------------------
diff --git a/tests/mechanisms/utils.py b/tests/mechanisms/utils.py
new file mode 100644
index 0000000..3475206
--- /dev/null
+++ b/tests/mechanisms/utils.py
@@ -0,0 +1,71 @@
+# 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
+
+
+def matrix(*iterables, **kwargs):
+    """
+    Generates a matrix of parameters for ``@pytest.mark.parametrize``.
+
+    The matrix is essentially the Cartesian product of the arguments (which 
should be iterables),
+    with the added ability to "flatten" each value by breaking up tuples and 
recombining them into a
+    final flat value.
+
+    To do such recombination, use the ``counts`` argument (tuple) to specify 
the number of elements
+    per value in order. Any count greater than 1 (the default) enables 
recombination of that value.
+
+    Example::
+
+      x = ('hello', 'goodbye')
+      y = ('Linus', 'Richard')
+      matrix(x, y) ->
+        ('hello', 'Linus'),
+        ('hello', 'Richard'),
+        ('goodbye', 'Linus'),
+        ('goodbye', 'Richard')
+
+      y = (('Linus', 'Torvalds'), ('Richard', 'Stallman'))
+      matrix(x, y) ->
+        ('hello', ('Linus', 'Torvalds')),
+        ('hello', ('Richard', 'Stallman')),
+        ('goodbye', ('Linus', 'Torvalds')),
+        ('goodbye', ('Richard', 'Stallman'))
+
+      matrix(x, y, counts=(1, 2)) ->
+        ('hello', 'Linus', 'Torvalds'),
+        ('hello', 'Richard', 'Stallman'),
+        ('goodbye', 'Linus', 'Torvalds'),
+        ('goodbye', 'Richard', 'Stallman')
+    """
+    counts = kwargs.get('counts')
+    for product in itertools.product(*iterables):
+        if counts:
+            elements = []
+            for value_index, value in enumerate(product):
+                try:
+                    count = counts[value_index]
+                except IndexError:
+                    count = 1
+                if count == 1:
+                    # As is
+                    elements.append(value)
+                else:
+                    # Recombine
+                    for element_index in range(count):
+                        elements.append(value[element_index])
+            yield tuple(elements)
+        else:
+            yield product

Reply via email to