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


More tests

* Introducing deepcopy_fast


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

Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 0f86ddc7f30c53daf0015775dc0e12860c3d86d6
Parents: c953990
Author: Tal Liron <[email protected]>
Authored: Fri Sep 29 16:06:12 2017 -0500
Committer: Tal Liron <[email protected]>
Committed: Fri Sep 29 16:06:12 2017 -0500

----------------------------------------------------------------------
 README.rst                                      |   8 +-
 aria/parser/presentation/presenter.py           |   4 +-
 aria/utils/collections.py                       |  31 +-
 .../simple_v1_0/templates/common/test_copy.py   |  17 +
 .../test_node_template_artifacts.py             |   4 +-
 .../test_node_template_capabilities.py          |  15 -
 .../test_node_template_node_filter.py           |  18 -
 ...est_node_template_node_filter_constraints.py |  17 +
 .../test_node_template_node_filters.py          | 266 ++++++
 .../test_node_template_requirements.py          | 843 +++++++++++++++++++
 .../simple_v1_0/templates/test_group.py         |   9 +-
 .../simple_v1_0/templates/test_policy.py        |  24 +-
 12 files changed, 1190 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/README.rst
----------------------------------------------------------------------
diff --git a/README.rst b/README.rst
index 6f8885c..7d64451 100644
--- a/README.rst
+++ b/README.rst
@@ -77,7 +77,6 @@ and run::
     # TODO
 
 
-
 To install ``pip``, either use your operating system's package management 
system, or run::
 
     wget http://bootstrap.pypa.io/get-pip.py
@@ -129,9 +128,10 @@ section).
 Resources
 ---------
 
-- `ARIA homepage <http://ariatosca.incubator.apache.org/>`__
-- `ARIA wiki <https://cwiki.apache.org/confluence/display/AriaTosca>`__
--  `Issue tracker <https://issues.apache.org/jira/browse/ARIA>`__
+- `Site <http://ariatosca.incubator.apache.org/>`__
+- `API and CLI documentation 
<http://ariatosca.incubator.apache.org/docs/html/>`__ 
+- `Wiki <https://cwiki.apache.org/confluence/display/AriaTosca>`__
+- `Issue tracker <https://issues.apache.org/jira/browse/ARIA>`__
 
 - Dev mailing list: [email protected]
 - User mailing list: [email protected]

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/aria/parser/presentation/presenter.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/presenter.py 
b/aria/parser/presentation/presenter.py
index e50b816..d2f3292 100644
--- a/aria/parser/presentation/presenter.py
+++ b/aria/parser/presentation/presenter.py
@@ -13,8 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from copy import deepcopy
-
 from ...utils.collections import merge
 from ...utils.formatting import safe_repr
 from ..validation import Issue
@@ -53,7 +51,7 @@ class Presenter(Presentation):
         return True
 
     def _merge_import(self, presentation):
-        merge(self._raw, deepcopy(presentation._raw))
+        merge(self._raw, presentation._raw)
         if hasattr(self._raw, '_locator') and hasattr(presentation._raw, 
'_locator'):
             self._raw._locator.merge(presentation._raw._locator)
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/aria/utils/collections.py
----------------------------------------------------------------------
diff --git a/aria/utils/collections.py b/aria/utils/collections.py
index ccc37a1..cfd8fda 100644
--- a/aria/utils/collections.py
+++ b/aria/utils/collections.py
@@ -19,6 +19,11 @@ Additional collection classes and collection utilities.
 
 from __future__ import absolute_import  # so we can import standard 
'collections'
 
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
+
 from copy import deepcopy
 try:
     from collections import OrderedDict
@@ -220,27 +225,30 @@ class StrictDict(OrderedDict):
         return super(StrictDict, self).__setitem__(key, value)
 
 
-def merge(dict_a, dict_b, path=None, strict=False):
+def merge(dict_a, dict_b, copy=True, strict=False, path=None):
     """
     Merges dicts, recursively.
     """
 
-    # TODO: a.add_yaml_merge(b), see https://bitbucket.org/ruamel/yaml/src/
-    # TODO: 
86622a1408e0f171a12e140d53c4ffac4b6caaa3/comments.py?fileviewer=file-view-default
+    # TODO: a.add_yaml_merge(b),
+    # see 
https://bitbucket.org/ruamel/yaml/src/86622a1408e0f171a12e140d53c4ffac4b6caaa3/
+    #     comments.py?fileviewer=file-view-default
 
     path = path or []
     for key, value_b in dict_b.iteritems():
         if key in dict_a:
             value_a = dict_a[key]
             if isinstance(value_a, dict) and isinstance(value_b, dict):
-                merge(value_a, value_b, path + [str(key)], strict)
+                if strict:
+                    path = path + [str(key)]
+                merge(value_a, value_b, copy, strict, path)
             elif value_a != value_b:
                 if strict:
                     raise ValueError('dict merge conflict at %s' % 
'.'.join(path + [str(key)]))
                 else:
-                    dict_a[key] = value_b
+                    dict_a[key] = deepcopy_fast(value_b) if copy else value_b
         else:
-            dict_a[key] = value_b
+            dict_a[key] = deepcopy_fast(value_b) if copy else value_b
     return dict_a
 
 
@@ -269,6 +277,15 @@ def prune(value, is_removable_function=is_removable):
     return value
 
 
+def deepcopy_fast(obj):
+    """
+    The builtin ``deepcopy`` is very slow due to detection of loops and other 
errors.
+
+    This version is surprisingly much faster.
+    """
+    return pickle.loads(pickle.dumps(obj))
+
+
 # TODO: Move following two methods to some place parser specific
 
 def deepcopy_with_locators(value):
@@ -276,7 +293,7 @@ def deepcopy_with_locators(value):
     Like :func:`~copy.deepcopy`, but also copies over locators.
     """
 
-    res = deepcopy(value)
+    res = deepcopy_fast(value)
     copy_locators(res, value)
     return res
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/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 e69de29..3593012 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
@@ -0,0 +1,17 @@
+# -*- 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/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py
index 70ca05a..d7c91a0 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py
@@ -31,7 +31,7 @@ topology_template:
     my_node:
       type: MyType
       artifacts: {{ caller()|indent(8) }}
-{% endmacro %}
+{%- endmacro %}
 """
 
 # Artifacts attached to a node type
@@ -40,7 +40,7 @@ TYPE_MACROS = """
 node_types:
   MyType:
     artifacts: {{ caller()|indent(6) }}
-{% endmacro %}
+{%- endmacro %}
 """
 
 MACROS = {

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py
deleted file mode 100644
index 8ca2ef7..0000000
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_capabilities.py
+++ /dev/null
@@ -1,15 +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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py
deleted file mode 100644
index 7fe2609..0000000
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter.py
+++ /dev/null
@@ -1,18 +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: both general and in requirements

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/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
new file mode 100644
index 0000000..3593012
--- /dev/null
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py
@@ -0,0 +1,17 @@
+# -*- 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/0f86ddc7/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
new file mode 100644
index 0000000..91ab6d7
--- /dev/null
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py
@@ -0,0 +1,266 @@
+# -*- 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
+
+
+MAIN_MACROS = """
+{% macro node_type() %}
+    {}
+{%- endmacro %}
+{% macro node_filter() %}
+      node_filter: {{ caller()|indent(8) }}
+{%- endmacro %}
+"""
+
+REQUIREMENT_MACROS = """
+{% macro node_type() %}
+    capabilities:
+      my_capability: MyType
+    requirements:
+      - my_requirement:
+          capability: MyType
+capability_types:
+  MyType: {}
+{%- endmacro %}
+{% macro node_filter() %}
+      requirements:
+        - my_requirement:
+            node: MyType
+            node_filter: {{ caller()|indent(14) }}
+{%- endmacro %}
+"""
+
+MACROS = {
+    'main': MAIN_MACROS,
+    'requirement': REQUIREMENT_MACROS
+}
+
+CASES = (
+    'main', 'requirement'
+)
+
+
[email protected]('macros,value', matrix(CASES, data.NOT_A_DICT))
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() -%}
+{{ value }}
+{% endcall %}
+""", dict(value=value)).assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+unsupported: {}
+{% endcall %}
+""").assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() -%}
+{}
+{% endcall %}
+""").assert_success()
+
+
+# Properties section
+
[email protected]('macros,value', matrix(CASES, data.NOT_A_LIST))
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+properties: {{ value }}
+{% endcall %}
+""", dict(value=value)).assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+properties: []
+{% endcall %}
+""").assert_success()
+
+
+# Capabilities section
+
[email protected]('macros,value', matrix(CASES, data.NOT_A_LIST))
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities: {{ value }}
+{% endcall %}
+""", dict(value=value)).assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities: []
+{% endcall %}
+""").assert_success()
+
+
+# Capability
+
[email protected]('macros,value', matrix(CASES, data.NOT_A_DICT))
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities:
+  - my_capability: {{ value }}
+{% endcall %}
+""", dict(value=value)).assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities:
+  - my_capability:
+      unsupported: {}
+{% endcall %}
+""").assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities:
+  - my_capability: {}
+{% endcall %}
+""").assert_success()
+
+
+# Capability properties section
+
[email protected]('macros,value', matrix(CASES, data.NOT_A_LIST))
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities:
+  - my_capability:
+      properties: {{ value }}
+{% endcall %}
+""", dict(value=value)).assert_failure()
+
+
[email protected]('macros', CASES)
+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() }}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+{%- call node_filter() %}
+capabilities:
+  - my_capability:
+      properties: []
+{% endcall %}
+""").assert_success()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py
 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py
index 8ca2ef7..fa52232 100644
--- 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py
+++ 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py
@@ -13,3 +13,846 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
+import pytest
+
+from ... import data
+
+
+# Section
+
[email protected]('value', data.NOT_A_LIST)
+def test_node_template_requirements_section_syntax_type(parser, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyType: {}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_template_requirements_section_syntax_empty(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyType: {}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements: []
+""").assert_success()
+
+
+# Requirement
+
[email protected]('value', data.NOT_A_DICT_OR_STRING)
+def test_node_template_requirement_syntax_type(parser, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyType: {}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_template_requirement_syntax_unsupported(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            unsupported: {}
+""").assert_failure()
+
+
+def test_node_template_requirement_empty(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement: {}
+""").assert_success()
+
+
+# Capability
+
+def test_node_template_requirement_capability_unknown(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: unknown # neither a type nor a name
+""").assert_failure()
+
+
+# Capability type
+
+def test_node_template_requirement_capability_type_same(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+""").assert_success()
+
+
+def test_node_template_requirement_capability_type_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType1
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_capability_type_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType1
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType2 # can change to anything
+""").assert_success()
+
+
+def test_node_template_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
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement: MyType
+""").assert_success()
+
+
+# Capability definition name
+
+def test_node_template_requirement_capability_name(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement: MyType
+  MyType2:
+    capabilities:
+      my_capability: MyType
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+            capability: my_capability
+    my_node2:
+      type: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_capability_name_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement: MyType1
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+            capability: my_capability
+    my_node2:
+      type: MyType2
+""").assert_success()
+
+
[email protected](reason='fix')
+def test_node_template_requirement_capability_name_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement: MyType1
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+            capability: my_capability
+    my_node2:
+      type: MyType2
+""").assert_failure()
+
+
+# Node
+
+def test_node_template_requirement_node_unknown(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            node: unknown
+""").assert_failure()
+
+
+# Node type
+
+def test_node_template_requirement_node_type_undefined(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement: MyType1
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_node_type_same(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_node_type_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+  MyType3:
+    derived_from: MyType2
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: MyType3
+""").assert_success()
+
+
[email protected](reason='fix')
+def test_node_template_requirement_node_type_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+  MyType3: {}
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: MyType3
+""").assert_failure()
+
+
+# Node template
+
+def test_node_template_requirement_node_template_undefined(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement: MyType1
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+    my_node2:
+      type: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_node_template_same(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+    my_node2:
+      type: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_node_template_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+  MyType3:
+    derived_from: MyType2
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+    my_node2:
+      type: MyType3
+""").assert_success()
+
+
[email protected](reason='fix')
+def test_node_template_requirement_node_template_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType1:
+    requirements:
+      - my_requirement:
+          capability: MyType1
+          node: MyType2
+  MyType2:
+    capabilities:
+      my_capability: MyType2
+  MyType3: {}
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+      requirements:
+        - my_requirement:
+            node: my_node2
+    my_node2:
+      type: MyType3
+""").assert_failure()
+
+
+# Relationship
+
+def test_node_template_requirement_relationship_syntax_unsupported(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
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: MyType
+              unsupported: {}
+""").assert_failure()
+
+
+def test_node_template_requirement_relationship_syntax_empty(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+relationship_types:
+  MyType: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement:
+          capability: MyType
+          relationship: MyType
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship: {}
+""").assert_success()
+
+
+def test_node_template_requirement_relationship_unknown(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
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship: unknown
+""").assert_failure()
+
+
+# Relationship type
+
+def test_node_template_requirement_relationship_type_same(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
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: MyType
+""").assert_success()
+
+
+def test_node_template_requirement_relationship_type_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+relationship_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType:
+    requirements:
+      - my_requirement:
+          capability: MyType
+          relationship: MyType1
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: MyType2
+""").assert_success()
+
+
+def test_node_template_requirement_relationship_type_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+relationship_types:
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement:
+          capability: MyType
+          relationship: MyType1
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: MyType2
+""").assert_failure()
+
+
+def test_node_template_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
+topology_template:
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship: MyType
+""").assert_success()
+
+
+# Relationship template
+
+def test_node_template_requirement_relationship_template_same(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
+topology_template:
+  relationship_templates:
+    my_relationship:
+      type: MyType
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: my_relationship
+""").assert_success()
+
+
+def test_node_template_requirement_relationship_template_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+relationship_types:
+  MyType1: {}
+  MyType2:
+    derived_from: MyType1
+node_types:
+  MyType:
+    requirements:
+      - my_requirement:
+          capability: MyType
+          relationship: MyType1
+topology_template:
+  relationship_templates:
+    my_relationship:
+      type: MyType2
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: my_relationship
+""").assert_success()
+
+
+def test_node_template_requirement_relationship_template_not_derived(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  MyType: {}
+relationship_types:
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
+node_types:
+  MyType:
+    requirements:
+      - my_requirement:
+          capability: MyType
+          relationship: MyType1
+topology_template:
+  relationship_templates:
+    my_relationship:
+      type: MyType2
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship:
+              type: my_relationship
+""").assert_failure()
+
+
+def test_node_template_requirement_relationship_template_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
+topology_template:
+  relationship_templates:
+    my_relationship:
+      type: MyType
+  node_templates:
+    my_node:
+      type: MyType
+      requirements:
+        - my_requirement:
+            capability: MyType
+            relationship: my_relationship
+""").assert_success()
+
+
+# Unicode
+
+def test_node_template_requirement_unicode(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+  類型: {}
+relationship_types:
+  類型: {}
+node_types:
+  類型:
+    requirements:
+      - 需求:
+          capability: 類型
+          relationship: 類型
+topology_template:
+  relationship_templates:
+    關係:
+      type: 類型
+  node_templates:
+    節點:
+      type: 類型
+      requirements:
+        - 需求:
+            capability: 類型
+            relationship: 關係
+""").assert_success()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py
index 8fd37c4..cf7f54d 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py
@@ -105,20 +105,19 @@ topology_template:
 """).assert_success()
 
 
-def test_group_members_derived_bad(parser):
+def test_group_members_not_derived(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 node_types:
   MyType1: {}
-  MyType2:
-    derived_from: MyType1
+  MyType2: {}
 group_types:
   MyType:
-    members: [ MyType2 ]
+    members: [ MyType1 ]
 topology_template:
   node_templates:
     my_node:
-      type: MyType1
+      type: MyType2
   groups:
     my_group:
       type: MyType

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0f86ddc7/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py
----------------------------------------------------------------------
diff --git 
a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py 
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py
index 28ee483..4828583 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py
@@ -105,20 +105,20 @@ topology_template:
 """).assert_success()
 
 
-def test_policy_targets_nodes_derived_bad(parser):
+def test_policy_targets_nodes_not_derived(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
 node_types:
-  MyType1: {}
-  MyType2:
-    derived_from: MyType1
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
 policy_types:
   MyType:
-    targets: [ MyType2 ]
+    targets: [ MyType1 ]
 topology_template:
   node_templates:
     my_node:
-      type: MyType1
+      type: MyType2
   policies:
     my_policy:
       type: MyType
@@ -169,20 +169,20 @@ topology_template:
 """).assert_success()
 
 
-def test_policy_targets_groups_derived_bad(parser):
+def test_policy_targets_groups_not_derived(parser):
     parser.parse_literal("""
 tosca_definitions_version: tosca_simple_yaml_1_0
-group_types:
   MyType1: {}
-  MyType2:
-    derived_from: MyType1
+  MyType1:
+    derived_from: MyType2
+  MyType2: {}
 policy_types:
   MyType:
-    targets: [ MyType2 ]
+    targets: [ MyType1 ]
 topology_template:
   groups:
     my_group:
-      type: MyType1
+      type: MyType2
   policies:
     my_policy:
       type: MyType


Reply via email to