Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-1-parser-test-suite 0f86ddc7f -> 740818ad4


Node filter tests.

* Fix for coercing node filter constraints that expect integers or
strings


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/740818ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/740818ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/740818ad

Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 740818ad4461317d102ceea6fe78dd4f86ebe6c6
Parents: 0f86ddc
Author: Tal Liron <[email protected]>
Authored: Mon Oct 2 16:18:07 2017 -0500
Committer: Tal Liron <[email protected]>
Committed: Mon Oct 2 16:18:07 2017 -0500

----------------------------------------------------------------------
 .../simple_v1_0/modeling/__init__.py            |  36 ++-
 .../aria_extension_tosca/simple_v1_0/data.py    |   3 +-
 .../simple_v1_0/templates/common/test_copy.py   |  37 ++-
 ...est_node_template_node_filter_constraints.py |  17 -
 .../test_node_template_node_filters.py          | 135 +++++---
 ...st_node_template_node_filters_constraints.py | 322 +++++++++++++++++++
 .../simple_v1_0/test_dsl_definitions.py         |  15 +-
 .../types/common/test_type_properties.py        |  16 +-
 8 files changed, 494 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py 
b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index d6d6c52..da326fa 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -29,7 +29,7 @@ from datetime import datetime
 from ruamel import yaml
 
 from aria.parser.validation import Issue
-from aria.utils.formatting import string_list_as_string
+from aria.utils.formatting import (string_list_as_string, safe_repr)
 from aria.utils.collections import (StrictDict, OrderedDict)
 from aria.orchestrator import WORKFLOW_DECORATOR_RESERVED_ARGUMENTS
 from aria.modeling.models import (Type, ServiceTemplate, NodeTemplate,
@@ -639,7 +639,8 @@ def create_node_filter_constraints(context, node_filter, 
target_node_template_co
         for property_name, constraint_clause in properties:
             constraint = create_constraint(context, node_filter, 
constraint_clause, property_name,
                                            None)
-            target_node_template_constraints.append(constraint)
+            if constraint is not None:
+                target_node_template_constraints.append(constraint)
 
     capabilities = node_filter.capabilities
     if capabilities is not None:
@@ -649,24 +650,33 @@ def create_node_filter_constraints(context, node_filter, 
target_node_template_co
                 for property_name, constraint_clause in properties:
                     constraint = create_constraint(context, node_filter, 
constraint_clause,
                                                    property_name, 
capability_name)
-                    target_node_template_constraints.append(constraint)
+                    if constraint is not None:
+                        target_node_template_constraints.append(constraint)
 
 
 def create_constraint(context, node_filter, constraint_clause, property_name, 
capability_name):     # pylint: disable=too-many-return-statements
+    if (not isinstance(constraint_clause._raw, dict)) or 
(len(constraint_clause._raw) != 1):
+        context.validation.report(
+            u'node_filter constraint is not a dict with one key: {0}'
+            .format(safe_repr(constraint_clause._raw)),
+            locator=node_filter._locator,
+            level=Issue.FIELD)
+        return None
+
     constraint_key = constraint_clause._raw.keys()[0]
 
     the_type = constraint_clause._get_type(context)
 
-    def coerce_constraint(constraint):
+    def coerce_constraint(constraint, the_type=the_type):
         if the_type is not None:
             return coerce_value(context, node_filter, the_type, None, None, 
constraint,
                                 constraint_key)
         else:
             return constraint
 
-    def coerce_constraints(constraints):
+    def coerce_constraints(constraints, the_type=the_type):
         if the_type is not None:
-            return tuple(coerce_constraint(constraint) for constraint in 
constraints)
+            return tuple(coerce_constraint(constraint, the_type) for 
constraint in constraints)
         else:
             return constraints
 
@@ -693,18 +703,22 @@ def create_constraint(context, node_filter, 
constraint_clause, property_name, ca
                            coerce_constraints(constraint_clause.valid_values))
     elif constraint_key == 'length':
         return Length(property_name, capability_name,
-                      coerce_constraint(constraint_clause.length))
+                      coerce_constraint(constraint_clause.length, int))
     elif constraint_key == 'min_length':
         return MinLength(property_name, capability_name,
-                         coerce_constraint(constraint_clause.min_length))
+                         coerce_constraint(constraint_clause.min_length, int))
     elif constraint_key == 'max_length':
         return MaxLength(property_name, capability_name,
-                         coerce_constraint(constraint_clause.max_length))
+                         coerce_constraint(constraint_clause.max_length, int))
     elif constraint_key == 'pattern':
         return Pattern(property_name, capability_name,
-                       coerce_constraint(constraint_clause.pattern))
+                       coerce_constraint(constraint_clause.pattern, unicode))
     else:
-        raise ValueError(u'malformed node_filter: {0}'.format(constraint_key))
+        context.validation.report(
+            u'unsupported node_filter constraint: {0}'.format(constraint_key),
+            locator=node_filter._locator,
+            level=Issue.FIELD)
+        return None
 
 
 def split_prefix(string):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
index dff3d2d..9f15538 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -38,11 +38,12 @@ PARAMETER_TYPE_NAMES = PRIMITIVE_TYPE_NAMES + ('MyType',)
 CONSTRAINTS_WITH_VALUE = ('equal', 'greater_than', 'greater_or_equal', 
'less_than', 'less_or_equal')
 CONSTRAINTS_WITH_VALUE_LIST = ('valid_values',)
 CONSTRAINTS_WITH_VALUE_RANGE = ('in_range',)
-CONSTRAINTS_WITH_NON_NEGATIVE_INT = ('length', 'min_length', 'max_length')
+CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT = ('length', 'min_length', 
'max_length')
 
 
 # Values
 
+PRIMITIVE_VALUES = ('null', 'true', 'a string', '123', '0.123', '[]', '{}')
 NOT_A_DICT = ('null', 'true', 'a string', '123', '0.123', '[]')
 NOT_A_DICT_OR_STRING = ('null', 'true', '123', '0.123', '[]')
 NOT_A_LIST = ('null', 'true', 'a string', '123', '0.123', '{}')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py
index 3593012..57eecad 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py
@@ -14,4 +14,39 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# TODO
+import pytest
+
+from ... import data
+
+
+CASES = ('node', 'relationship')
+
+
[email protected]('name', CASES)
+def test_templates_copy(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+  MyType: {}
+topology_template:
+  {{ section }}:
+    my_template:
+      type: MyType
+    copy_template:
+      copy: my_template
+""", dict(name=name, 
section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
[email protected]('name', CASES)
+def test_templates_copy_unknown(parser, name):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+  MyType: {}
+topology_template:
+  {{ section }}:
+    my_template:
+      type: MyType
+    copy_template:
+      copy: unknown
+""", dict(name=name, 
section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py
deleted file mode 100644
index 3593012..0000000
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# TODO

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
index 91ab6d7..bed3a62 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
@@ -21,29 +21,46 @@ from ... import data
 from ......mechanisms.utils import matrix
 
 
+# Node filter in node template
 MAIN_MACROS = """
-{% macro node_type() %}
-    {}
+{% macro additions() %}
+node_types:
+  MyType1: {}
+  MyType2:
+    properties:
+      my_property:
+        type: string
 {%- endmacro %}
 {% macro node_filter() %}
       node_filter: {{ caller()|indent(8) }}
 {%- endmacro %}
 """
 
+
+# Node filter in requirement
 REQUIREMENT_MACROS = """
-{% macro node_type() %}
-    capabilities:
-      my_capability: MyType
+{% macro additions() %}
+capability_types:
+  MyType:
+    properties:
+      my_property:
+        type: string
+node_types:
+  MyType1:
     requirements:
       - my_requirement:
           capability: MyType
-capability_types:
-  MyType: {}
+  MyType2:
+    properties:
+      my_property:
+        type: string
+    capabilities:
+      my_capability: MyType
 {%- endmacro %}
 {% macro node_filter() %}
       requirements:
         - my_requirement:
-            node: MyType
+            node: MyType2
             node_filter: {{ caller()|indent(14) }}
 {%- endmacro %}
 """
@@ -62,12 +79,11 @@ CASES = (
 def test_node_template_node_filter_syntax_type(parser, macros, value):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() -%}
 {{ value }}
 {% endcall %}
@@ -78,12 +94,11 @@ topology_template:
 def test_node_template_node_filter_syntax_unsupported(parser, macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 unsupported: {}
 {% endcall %}
@@ -94,12 +109,11 @@ unsupported: {}
 def test_node_template_node_filter_syntax_empty(parser, macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() -%}
 {}
 {% endcall %}
@@ -112,12 +126,11 @@ topology_template:
 def test_node_template_node_filter_properties_section_syntax_type(parser, 
macros, value):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 properties: {{ value }}
 {% endcall %}
@@ -128,12 +141,11 @@ properties: {{ value }}
 def test_node_template_node_filter_properties_section_syntax_empty(parser, 
macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 properties: []
 {% endcall %}
@@ -146,12 +158,11 @@ properties: []
 def test_node_template_node_filter_capabilities_section_syntax_type(parser, 
macros, value):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities: {{ value }}
 {% endcall %}
@@ -162,12 +173,11 @@ capabilities: {{ value }}
 def test_node_template_node_filter_capabilities_section_syntax_empty(parser, 
macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities: []
 {% endcall %}
@@ -180,12 +190,11 @@ capabilities: []
 def test_node_template_node_filter_capability_syntax_type(parser, macros, 
value):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities:
   - my_capability: {{ value }}
@@ -197,12 +206,11 @@ capabilities:
 def test_node_template_node_filter_capability_syntax_unsupported(parser, 
macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities:
   - my_capability:
@@ -215,12 +223,11 @@ capabilities:
 def test_node_template_node_filter_capability_syntax_empty(parser, macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities:
   - my_capability: {}
@@ -234,12 +241,11 @@ capabilities:
 def 
test_node_template_node_filter_capability_properties_section_syntax_type(parser,
 macros, value):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities:
   - my_capability:
@@ -252,15 +258,56 @@ capabilities:
 def 
test_node_template_node_filter_capability_properties_section_syntax_empty(parser,
 macros):
     parser.parse_literal(MACROS[macros] + """
 tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
-  MyType: {{- node_type() }}
+{{- additions() }}
 topology_template:
   node_templates:
     my_node:
-      type: MyType
+      type: MyType1
 {%- call node_filter() %}
 capabilities:
   - my_capability:
       properties: []
 {% endcall %}
 """).assert_success()
+
+
+# Unicode
+
+def test_node_template_node_filter_unicode(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  類型: {}
+node_types:
+  類型一:
+    requirements:
+      - 需求:
+          capability: 類型
+  類型二:
+    properties:
+      屬性:
+        type: string
+    capabilities:
+      能力: 類型
+topology_template:
+  node_templates:
+    模板:
+      type: 類型一
+      node_filter:
+        properties:
+          - 屬性: { equal: 值 }
+        capabilities:
+          - my_capability:
+               properties:
+                 - 屬性: { equal: 值 }
+      requirements:
+        - 需求:
+            node: 類型二
+            node_filter:
+              properties:
+                - 屬性: { equal: 值 }
+              capabilities:
+                - 能力:
+                    properties:
+                      - 屬性: { equal: 值 }
+""").assert_success()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py
new file mode 100644
index 0000000..cb55803
--- /dev/null
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py
@@ -0,0 +1,322 @@
+# -*- 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
+
+
+# Properties for node filter in node template
+MAIN_MACROS = """
+{% macro additions() %}
+data_types:
+  MyType:
+    properties:
+      my_field:
+        type: string
+node_types:
+  MyType1: {}
+  MyType2:
+    properties:
+      data_property:
+        type: MyType
+      string_property:
+        type: string
+{%- endmacro %}
+{% macro properties() %}
+      node_filter:
+        properties: {{ caller()|indent(10) }}
+{%- endmacro %}
+"""
+
+# Capability properties for node filter in node template
+MAIN_CAPABILITY_MACROS = """
+{% macro additions() %}
+data_types:
+  MyType:
+    properties:
+      my_field:
+        type: string
+capability_types:
+  MyType:
+    properties:
+      data_property:
+        type: MyType
+      string_property:
+        type: string
+node_types:
+  MyType1: {}
+  MyType2:
+    capabilities:
+      my_capability: MyType
+{%- endmacro %}
+{% macro properties() %}
+      node_filter:
+        capabilities:
+          - my_capability:
+              properties: {{ caller()|indent(16) }}
+{%- endmacro %}
+"""
+
+# Properties for node filter in requirement
+REQUIREMENT_MACROS = """
+{% macro additions() %}
+data_types:
+  MyType:
+    properties:
+      my_field:
+        type: string
+capability_types:
+  MyType: {}
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType
+  MyType2:
+    properties:
+      data_property:
+        type: MyType
+      string_property:
+        type: string
+    capabilities:
+      my_capability: MyType
+{%- endmacro %}
+{% macro properties() %}
+      requirements:
+        - my_requirement:
+            node: MyType2
+            node_filter:
+              properties: {{ caller()|indent(16) }}
+{%- endmacro %}
+"""
+
+# Capability properties for node filter in requirement
+REQUIREMENT_CAPABILITY_MACROS = """
+{% macro additions() %}
+data_types:
+  MyType:
+    properties:
+      my_field:
+        type: string
+capability_types:
+  MyType:
+    properties:
+      data_property:
+        type: MyType
+      string_property:
+        type: string
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType
+  MyType2:
+    capabilities:
+      my_capability: MyType
+{%- endmacro %}
+{% macro properties() %}
+      requirements:
+        - my_requirement:
+            node: MyType2
+            node_filter:
+              capabilities:
+                - my_capability:
+                    properties: {{ caller()|indent(22) }}
+{%- endmacro %}
+"""
+
+MACROS = {
+    'main': MAIN_MACROS,
+    'requirement': REQUIREMENT_MACROS,
+    'main-capability': MAIN_CAPABILITY_MACROS,
+    'requirement-capability': REQUIREMENT_CAPABILITY_MACROS
+}
+
+CASES = (
+    'main', 'requirement', 'main-capability', 'requirement-capability'
+)
+
+
+
[email protected]('macros', CASES)
+def test_node_template_node_filter_constraints_syntax_empty(parser, macros):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: {}
+{% endcall %}
+""").assert_failure()
+
+
[email protected]('macros', CASES)
+def test_node_template_node_filter_constraints_syntax_unsupported(parser, 
macros):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { unsupported: a string }
+{% endcall %}
+""").assert_failure()
+
+
[email protected]('macros,constraint', matrix(CASES, 
data.CONSTRAINTS_WITH_VALUE))
+def test_node_template_node_filter_constraints_with_value(parser, macros, 
constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { {{ constraint }}: {my_field: a string} }
+{% endcall %}
+""", dict(constraint=constraint)).assert_success()
+
+
[email protected]('macros,constraint', matrix(CASES, 
data.CONSTRAINTS_WITH_VALUE_LIST))
+def test_node_template_node_filter_constraints_with_value_list(parser, macros, 
constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, 
{my_field: c} ] }
+{% endcall %}
+""", dict(constraint=constraint)).assert_success()
+
+
[email protected]('macros,constraint', matrix(CASES, 
data.CONSTRAINTS_WITH_VALUE_RANGE))
+def test_node_template_node_filter_constraints_with_value_range(parser, 
macros, constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { {{ constraint }}: [ {my_field: string a}, {my_field: string 
b} ] }
+{% endcall %}
+""", dict(constraint=constraint)).assert_success()
+
+
[email protected]('macros,constraint', matrix(CASES, 
data.CONSTRAINTS_WITH_VALUE_RANGE))
+def 
test_node_template_node_filter_constraints_with_value_range_too_many(parser, 
macros,
+                                                                         
constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, 
{my_field: c} ] }
+{% endcall %}
+""", dict(constraint=constraint)).assert_failure()
+
+
[email protected]('macros,constraint', matrix(CASES, 
data.CONSTRAINTS_WITH_VALUE_RANGE))
+def test_node_template_node_filter_constraints_with_value_range_bad(parser, 
macros, constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- data_property: { {{ constraint }}: [ {my_field: string b}, {my_field: string 
a} ] }
+{% endcall %}
+""", dict(constraint=constraint)).assert_failure()
+
+
[email protected]('macros', CASES)
+def test_node_template_node_filter_constraints_pattern(parser, macros):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- string_property: { pattern: ^pattern$ }
+{% endcall %}
+""").assert_success()
+
+
[email protected]('macros', CASES)
+def test_node_template_node_filter_constraints_pattern_bad(parser, macros):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- string_property: { pattern: ( }
+{% endcall %}
+""").assert_failure()
+
+
[email protected]('macros,constraint', matrix(CASES,
+                                                     
data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT))
+def test_node_template_node_filter_constraints_with_value_integer(parser, 
macros, constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- string_property: { {{ constraint }}: 1 }
+{% endcall %}
+""", dict(constraint=constraint)).assert_success()
+
+
[email protected]('macros,constraint', matrix(CASES,
+                                                     
data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT))
+def test_node_template_node_filter_constraints_with_value_integer_bad(parser, 
macros, constraint):
+    parser.parse_literal(MACROS[macros] + """
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+{%- call properties() %}
+- string_property: { {{ constraint }}: -1 }
+{% endcall %}
+""", dict(constraint=constraint)).assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/test_dsl_definitions.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/test_dsl_definitions.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/test_dsl_definitions.py
index 9bb526e..3defb70 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_dsl_definitions.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_dsl_definitions.py
@@ -14,19 +14,24 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import pytest
 
-def test_dsl_definitions_syntax_empty(parser):
+from . import data
+
+
[email protected]('value', data.PRIMITIVE_VALUES)
+def test_dsl_definitions_syntax_anything(parser, value):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
-dsl_definitions: {}
-""").assert_success()
+dsl_definitions: {{ value }}
+""", dict(value=value)).assert_success()
 
 
-def test_dsl_definitions(parser):
+def test_dsl_definitions_anchor(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 dsl_definitions:
-  dsl_definition: &ANCHOR
+  key: &ANCHOR
     field: a value
 """).assert_success()
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/740818ad/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_properties.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_properties.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_properties.py
index 5e06561..6844ce6 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_properties.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_properties.py
@@ -266,8 +266,8 @@ my_parameter:
     data.CONSTRAINTS_WITH_VALUE_RANGE,
     counts=(3, 1)
 ))
-def test_type_parameter_constraints_with_value_range_invalid(macros, parser, 
name,
-                                                             
parameter_section, constraint):
+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
 {{- additions() }}
@@ -325,11 +325,11 @@ my_parameter:
 
 @pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
     CASES,
-    data.CONSTRAINTS_WITH_NON_NEGATIVE_INT,
+    data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT,
     counts=(3, 1)
 ))
-def test_type_parameter_constraints_with_integer(parser, macros, name, 
parameter_section,
-                                                 constraint):
+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() }}
@@ -346,11 +346,11 @@ my_parameter:
 
 @pytest.mark.parametrize('macros,name,parameter_section,constraint', matrix(
     CASES,
-    data.CONSTRAINTS_WITH_NON_NEGATIVE_INT,
+    data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT,
     counts=(3, 1)
 ))
-def test_type_parameter_constraints_with_integer_bad(parser, macros, name, 
parameter_section,
-                                                     constraint):
+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() }}

Reply via email to