ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject [1/2] incubator-ariatosca git commit: Support Unicode for reporting [Forced Update!]
Date Tue, 12 Sep 2017 00:28:17 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-1-parser-test-suite 756356ab6 -> c01e8840c (forced update)


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
index 180ba28..6a0af90 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py
@@ -88,7 +88,7 @@ def get_assigned_and_defined_parameter_values(context, presentation, field_name)
                 definition = definitions[name]
                 values[name] = coerce_parameter_value(context, value, definition, value.value)
             else:
-                context.validation.report('assignment to undefined {0} "{1}" in "{2}"'
+                context.validation.report(u'assignment to undefined {0} "{1}" in "{2}"'
                                           .format(field_name, name, presentation._fullname),
                                           locator=value._locator, level=Issue.BETWEEN_TYPES)
 
@@ -150,7 +150,7 @@ def validate_required_values(context, presentation, values, definitions):
     for name, definition in definitions.iteritems():
         if getattr(definition, 'required', False) \
             and ((values is None) or (values.get(name) is None)):
-            context.validation.report('required property "{0}" is not assigned a value in
"{1}"'
+            context.validation.report(u'required property "{0}" is not assigned a value in
"{1}"'
                                       .format(name, presentation._fullname),
                                       locator=presentation._get_child_locator('properties'),
                                       level=Issue.BETWEEN_TYPES)
@@ -169,8 +169,8 @@ def merge_raw_parameter_definition(context, presentation, raw_property_definitio
     if type1 != type2:
         if not hasattr(type1, '_is_descendant') or not type1._is_descendant(context, type2):
             context.validation.report(
-                'property definition type "{0}" is not a descendant of overridden '
-                'property definition type "{1}"' \
+                u'property definition type "{0}" is not a descendant of overridden '
+                u'property definition type "{1}"' \
                 .format(type1_name, type2._name),
                 locator=presentation._get_child_locator(field_name, property_name),
                 level=Issue.BETWEEN_TYPES)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
index 6bdb5b1..0b56e9d 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
@@ -107,24 +107,25 @@ def get_template_requirements(context, presentation):
                     requirement_assignments.append((requirement_name, requirement_assignment))
                 elif actual_occurrences > 1:
                     context.validation.report(
-                        'requirement "%s" is allowed only one occurrence in "%s": %d'
-                        % (requirement_name, presentation._fullname, actual_occurrences),
+                        u'requirement "{0}" is allowed only one occurrence in "{1}": {2:d}'
+                        .format(requirement_name, presentation._fullname, actual_occurrences),
                         locator=presentation._locator, level=Issue.BETWEEN_TYPES)
             else:
                 if not allowed_occurrences.is_in(actual_occurrences):
                     if allowed_occurrences.value[1] == 'UNBOUNDED':
                         context.validation.report(
-                            'requirement "%s" does not have at least %d occurrences in "%s":
has %d'
-                            % (requirement_name, allowed_occurrences.value[0],
-                               presentation._fullname, actual_occurrences),
+                            u'requirement "{0}" does not have at least {1:d} occurrences
in "{3}":'
+                            u' has {4:d}'
+                            .format(requirement_name, allowed_occurrences.value[0],
+                                    presentation._fullname, actual_occurrences),
                             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
                     else:
                         context.validation.report(
-                            'requirement "%s" is allowed between %d and %d occurrences in
"%s":'
-                            ' has %d'
-                            % (requirement_name, allowed_occurrences.value[0],
-                               allowed_occurrences.value[1], presentation._fullname,
-                               actual_occurrences),
+                            u'requirement "{0}" is allowed between {1:d} and {2:d} occurrences
in'
+                            u' "{3}": has {4:d}'
+                            .format(requirement_name, allowed_occurrences.value[0],
+                                    allowed_occurrences.value[1], presentation._fullname,
+                                    actual_occurrences),
                             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
 
     return requirement_assignments
@@ -174,9 +175,9 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin
         # Make sure the type is derived
         if not definition_relationship_type._is_descendant(context, relationship_type):
             context.validation.report(
-                'assigned relationship type "%s" is not a descendant of declared relationship
type'
-                ' "%s"' \
-                % (relationship_type._name, definition_relationship_type._name),
+                u'assigned relationship type "{0}" is not a descendant of declared relationship
'
+                u' type "{1}"'
+                .format(relationship_type._name, definition_relationship_type._name),
                 locator=container._locator, level=Issue.BETWEEN_TYPES)
 
     if relationship_type is not None:
@@ -256,9 +257,9 @@ def add_requirement_assignments(context, presentation, requirement_assignments,
                                             relationship_interface_definitions)
             requirement_assignments.append((requirement_name, requirement_assignment))
         else:
-            context.validation.report('requirement "%s" not declared at node type "%s" in
"%s"'
-                                      % (requirement_name, presentation.type,
-                                         presentation._fullname),
+            context.validation.report(u'requirement "{0}" not declared at node type "{1}"
in "{2}"'
+                                      .format(requirement_name, presentation.type,
+                                              presentation._fullname),
                                       locator=our_requirement_assignment._locator,
                                       level=Issue.BETWEEN_TYPES)
 
@@ -305,10 +306,10 @@ def merge_requirement_assignment_relationship(context, presentation,
property_de
                     coerce_parameter_value(context, presentation, definition, prop)
             else:
                 context.validation.report(
-                    'relationship property "%s" not declared at definition of requirement
"%s"'
-                    ' in "%s"'
-                    % (property_name, requirement._fullname,
-                       presentation._container._container._fullname),
+                    u'relationship property "{0}" not declared at definition of requirement
"{1}"'
+                    u' in "{2}"'
+                    .format(property_name, requirement._fullname,
+                            presentation._container._container._fullname),
                     locator=our_relationship._get_child_locator('properties', property_name),
                     level=Issue.BETWEEN_TYPES)
 
@@ -330,10 +331,10 @@ def merge_requirement_assignment_relationship(context, presentation,
property_de
                                 interface_definition, interface_name)
             else:
                 context.validation.report(
-                    'relationship interface "%s" not declared at definition of requirement
"%s"'
-                    ' in "%s"'
-                    % (interface_name, requirement._fullname,
-                       presentation._container._container._fullname),
+                    u'relationship interface "{0}" not declared at definition of requirement
"{1}"'
+                    u' in "{2}"'
+                    .format(interface_name, requirement._fullname,
+                            presentation._container._container._fullname),
                     locator=our_relationship._locator, level=Issue.BETWEEN_TYPES)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
index e2af4b8..2bbc437 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py
@@ -29,7 +29,7 @@ def validate_substitution_mappings_requirement(context, presentation):
             break
     else:
         context.validation.report(
-            'substitution mapping requirement "{0}" is not declared in node type "{1}"'.format(
+            u'substitution mapping requirement "{0}" is not declared in node type "{1}"'.format(
                 presentation._name, substitution_node_type._name),
             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
         return
@@ -50,8 +50,8 @@ def validate_substitution_mappings_requirement(context, presentation):
             break
     else:
         context.validation.report(
-            'substitution mapping requirement "{0}" refers to an unknown requirement of node
'
-            'template "{1}": {mapped_requirement_name}'.format(
+            u'substitution mapping requirement "{0}" refers to an unknown requirement of
node '
+            u'template "{1}": {mapped_requirement_name}'.format(
                 presentation._name, node_template._name,
                 mapped_requirement_name=safe_repr(mapped_requirement_name)),
             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
@@ -66,8 +66,8 @@ def validate_substitution_mappings_requirement(context, presentation):
     if not node_template_requirement_capability_type._is_descendant(
             context, substitution_type_requirement_capability_type):
         context.validation.report(
-            'substitution mapping requirement "{0}" of capability type "{1}" is not a descendant
'
-            'of the mapped node template capability type "{2}"'.format(
+            u'substitution mapping requirement "{0}" of capability type "{1}" is not a descendant
'
+            u'of the mapped node template capability type "{2}"'.format(
                 presentation._name,
                 substitution_type_requirement_capability_type._name,
                 node_template_requirement_capability_type._name),
@@ -84,8 +84,8 @@ def validate_substitution_mappings_capability(context, presentation):
     substitution_type_capability = substitution_type_capabilities.get(presentation._name)
     if substitution_type_capability is None:
         context.validation.report(
-            'substitution mapping capability "{0}" '
-            'is not declared in node type "{substitution_type}"'.format(
+            u'substitution mapping capability "{0}" '
+            u'is not declared in node type "{substitution_type}"'.format(
                 presentation._name, substitution_type=substitution_node_type._name),
             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
         return
@@ -105,8 +105,8 @@ def validate_substitution_mappings_capability(context, presentation):
 
     if node_template_capability is None:
         context.validation.report(
-            'substitution mapping capability "{0}" refers to an unknown '
-            'capability of node template "{1}": {mapped_capability_name}'.format(
+            u'substitution mapping capability "{0}" refers to an unknown '
+            u'capability of node template "{1}": {mapped_capability_name}'.format(
                 presentation._name, node_template._name,
                 mapped_capability_name=safe_repr(mapped_capability_name)),
             locator=presentation._locator, level=Issue.BETWEEN_TYPES)
@@ -119,8 +119,8 @@ def validate_substitution_mappings_capability(context, presentation):
 
     if not substitution_type_capability_type._is_descendant(context, node_template_capability_type):
         context.validation.report(
-            'node template capability type "{0}" is not a descendant of substitution mapping
'
-            'capability "{1}" of type "{2}"'.format(
+            u'node template capability type "{0}" is not a descendant of substitution mapping
'
+            u'capability "{1}" of type "{2}"'.format(
                 node_template_capability_type._name,
                 presentation._name,
                 substitution_type_capability_type._name),
@@ -150,8 +150,8 @@ def _get_node_template(context, presentation):
 
 def _report_missing_node_template(context, presentation, field):
     context.validation.report(
-        'substitution mappings {field} "{node_template_mapping}" '
-        'refers to an unknown node template: {node_template_name}'.format(
+        u'substitution mappings {field} "{node_template_mapping}" '
+        u'refers to an unknown node template: {node_template_name}'.format(
             field=field,
             node_template_mapping=presentation._name,
             node_template_name=safe_repr(presentation._raw[0])),
@@ -160,7 +160,7 @@ def _report_missing_node_template(context, presentation, field):
 
 def _report_invalid_mapping_format(context, presentation, field):
     context.validation.report(
-        'substitution mapping {field} "{field_name}" is not a list of 2 strings: {value}'.format(
+        u'substitution mapping {field} "{field_name}" is not a list of 2 strings: {value}'.format(
             field=field,
             field_name=presentation._name,
             value=safe_repr(presentation._raw)),

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
index 6c424a4..9cd58e2 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_getters.py
@@ -34,7 +34,7 @@ def data_type_class_getter(cls, allow_null=False):
             return cls(None, None, raw, None)
         except ValueError as e:
             raise InvalidValueError(
-                '{0} is not a valid "{1}" in "{2}": {3}'
+                u'{0} is not a valid "{1}" in "{2}": {3}'
                 .format(field.full_name, full_type_name(cls), presentation._name,
                         safe_repr(raw)),
                 cause=e, locator=field.get_locator(raw))

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py
b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py
index 9c88cfe..d5c585e 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py
@@ -52,7 +52,7 @@ def copy_validator(template_type_name, templates_dict_name):
             else:
                 if copy.copy is not None:
                     context.validation.report(
-                        '"copy" field refers to a {0} that itself is a copy in "{1}": {2}'
+                        u'"copy" field refers to a {0} that itself is a copy in "{1}": {2}'
                         .format(template_type_name, presentation._fullname, safe_repr(value)),
                         locator=presentation._locator, level=Issue.BETWEEN_TYPES)
 
@@ -84,7 +84,7 @@ def data_type_validator(type_name='data type'):
             container_data_type = get_container_data_type(presentation)
             if (container_data_type is not None) and (container_data_type._name == value):
                 context.validation.report(
-                    'type of property "{0}" creates a circular value hierarchy: {1}'
+                    u'type of property "{0}" creates a circular value hierarchy: {1}'
                     .format(presentation._fullname, safe_repr(value)),
                     locator=presentation._get_child_locator('type'), level=Issue.BETWEEN_TYPES)
 
@@ -135,13 +135,13 @@ def entry_schema_validator(field, presentation, context):
     if use_entry_schema:
         if value is None:
             context.validation.report(
-                '"entry_schema" does not have a value as required by data type "{0}" in "{1}"'
+                u'"entry_schema" does not have a value as required by data type "{0}" in
"{1}"'
                 .format(get_data_type_name(the_type), presentation._container._fullname),
                 locator=presentation._locator, level=Issue.BETWEEN_TYPES)
     else:
         if value is not None:
             context.validation.report(
-                '"entry_schema" has a value but it is not used by data type "{0}" in "{1}"'
+                u'"entry_schema" has a value but it is not used by data type "{0}" in "{1}"'
                 .format(get_data_type_name(the_type), presentation._container._fullname),
                 locator=presentation._locator, level=Issue.BETWEEN_TYPES)
 
@@ -201,7 +201,7 @@ def data_type_constraints_validator(field, presentation, context):
     if value is not None:
         if presentation._get_primitive_ancestor(context) is None:
             context.validation.report(
-                'data type "{0}" defines constraints but does not have a primitive ancestor'
+                u'data type "{0}" defines constraints but does not have a primitive ancestor'
                 .format(presentation._fullname),
                 locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
 
@@ -220,7 +220,7 @@ def data_type_properties_validator(field, presentation, context):
     if values is not None:
         if presentation._get_primitive_ancestor(context) is not None:
             context.validation.report(
-                'data type "{0}" defines properties even though it has a primitive ancestor'
+                u'data type "{0}" defines properties even though it has a primitive ancestor'
                 .format(presentation._fullname),
                 locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
 
@@ -275,14 +275,14 @@ def constraint_clause_in_range_validator(field, presentation, context):
                 # Second "in_range" value must be greater or equal than first
                 if (lower is not None) and (upper is not None) and (lower >= upper):
                     context.validation.report(
-                        'upper bound of "in_range" constraint is not greater than the lower
bound'
-                        ' in "{0}": {1} <= {2}'
+                        u'upper bound of "in_range" constraint is not greater than the lower
bound'
+                        u' in "{0}": {1} <= {2}'
                         .format(presentation._container._fullname, safe_repr(lower),
                                 safe_repr(upper)),
                         locator=presentation._locator, level=Issue.FIELD)
         else:
             context.validation.report(
-                'constraint "{0}" is not a list of exactly 2 elements in "{1}": {2}'
+                u'constraint "{0}" is not a list of exactly 2 elements in "{1}": {2}'
                 .format(field.name, presentation._fullname, safe_repr(values)),
                 locator=presentation._get_child_locator(field.name), level=Issue.FIELD)
 
@@ -326,7 +326,7 @@ def constraint_clause_pattern_validator(field, presentation, context):
             re.compile(value)
         except re.error as e:
             context.validation.report(
-                'constraint "{0}" is not a valid regular expression in "{1}": {2}'
+                u'constraint "{0}" is not a valid regular expression in "{1}": {2}'
                 .format(field.name, presentation._fullname, safe_repr(value)),
                 locator=presentation._get_child_locator(field.name), level=Issue.FIELD, exception=e)
 
@@ -380,20 +380,20 @@ def capability_definition_or_type_validator(field, presentation, context):
         if get_type_by_name(context, value, 'capability_types') is not None:
             if node is not None:
                 context.validation.report(
-                    '"{0}" refers to a capability type even though "node" has a value in
"{1}"'
+                    u'"{0}" refers to a capability type even though "node" has a value in
"{1}"'
                     .format(presentation._name, presentation._container._fullname),
                     locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_FIELDS)
             return
 
         if node_variant == 'node_template':
             context.validation.report(
-                'requirement "{0}" refers to an unknown capability definition name or capability'
-                ' type in "{1}": {2}'
+                u'requirement "{0}" refers to an unknown capability definition name or capability'
+                u' type in "{1}": {2}'
                 .format(presentation._name, presentation._container._fullname, safe_repr(value)),
                 locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
         else:
             context.validation.report(
-                'requirement "{0}" refers to an unknown capability type in "{1}": {2}'
+                u'requirement "{0}" refers to an unknown capability type in "{1}": {2}'
                 .format(presentation._name, presentation._container._fullname, safe_repr(value)),
                 locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
 
@@ -413,8 +413,8 @@ def node_filter_validator(field, presentation, context):
         _, node_type_variant = presentation._get_node(context)
         if node_type_variant != 'node_type':
             context.validation.report(
-                'requirement "{0}" has a node filter even though "node" does not refer to
a node'
-                ' type in "{1}"'
+                u'requirement "{0}" has a node filter even though "node" does not refer to
a node'
+                u' type in "{1}"'
                 .format(presentation._fullname, presentation._container._fullname),
                 locator=presentation._locator, level=Issue.BETWEEN_FIELDS)
 
@@ -520,8 +520,8 @@ def policy_targets_validator(field, presentation, context):
 
             if not is_valid:
                 context.validation.report(
-                    'policy definition target does not match either a node type or a group
type'
-                    ' declared in the policy type in "{0}": {1}'
+                    u'policy definition target does not match either a node type or a group
type'
+                    u' declared in the policy type in "{0}": {1}'
                     .format(presentation._name, safe_repr(value)),
                     locator=presentation._locator, level=Issue.BETWEEN_TYPES)
 
@@ -548,7 +548,7 @@ def node_filter_properties_validator(field, presentation, context):
             for name, _ in values:
                 if name not in properties:
                     context.validation.report(
-                        'node filter refers to an unknown property definition in "{0}": {1}'
+                        u'node filter refers to an unknown property definition in "{0}":
{1}'
                         .format(node_type._name, name),
                         locator=presentation._locator, level=Issue.BETWEEN_TYPES)
 
@@ -578,12 +578,12 @@ def node_filter_capabilities_validator(field, presentation, context):
                         for property_name, _ in properties:
                             if property_name not in capability_properties:
                                 context.validation.report(
-                                    'node filter refers to an unknown capability definition'
-                                    ' property in "{0}": {1}'
+                                    u'node filter refers to an unknown capability definition'
+                                    u' property in "{0}": {1}'
                                     .format(node_type._name, property_name),
                                     locator=presentation._locator, level=Issue.BETWEEN_TYPES)
                 else:
                     context.validation.report(
-                        'node filter refers to an unknown capability definition in "{0}":
{1}'
+                        u'node filter refers to an unknown capability definition in "{0}":
{1}'
                         .format(node_type._name, name),
                         locator=presentation._locator, level=Issue.BETWEEN_TYPES)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py
new file mode 100644
index 0000000..641c2bf
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py
@@ -0,0 +1,186 @@
+# -*- 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_template_targets_wrong_yaml_type(parser, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+  MyType: {}
+topology_template:
+  policies:
+    my_policy:
+      type: MyType
+      targets: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_policy_template_targets_element_wrong_yaml_type(parser, value):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+  MyType: {}
+topology_template:
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_policy_template_targets_empty(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+  MyType: {}
+topology_template:
+  policies:
+    my_policy:
+      type: MyType
+      targets: []
+""").assert_success()
+
+
+def test_policy_template_targets_nodes(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyType1: {}
+  MyType2: {}
+policy_types:
+  MyType:
+    targets: [ MyType1, MyType2 ]
+topology_template:
+  node_templates:
+    my_node1:
+      type: MyType1
+    my_node2:
+      type: MyType2
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ my_node1, my_node2 ]
+""").assert_success()
+
+
+def test_policy_template_targets_groups(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+  MyType1: {}
+  MyType2: {}
+policy_types:
+  MyType:
+    targets: [ MyType1, MyType2 ]
+topology_template:
+  groups:
+    my_group1:
+      type: MyType1
+    my_group2:
+      type: MyType2
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ my_group1, my_group2 ]
+""").assert_success()
+
+
+def test_policy_template_targets_nodes_and_groups(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyNodeType: {}
+group_types:
+  MyGroupType: {}
+policy_types:
+  MyType:
+    targets: [ MyNodeType, MyGroupType ]
+topology_template:
+  node_templates:
+    my_node:
+      type: MyNodeType
+  groups:
+    my_group:
+      type: MyGroupType
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ my_node, my_group ]
+""").assert_success()
+
+
+def test_policy_template_targets_ambiguous(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  MyNodeType: {}
+group_types:
+  MyGroupType: {}
+policy_types:
+  MyType:
+    targets: [ MyNodeType, MyGroupType ]
+topology_template:
+  node_templates:
+    my_template:
+      type: MyNodeType
+  groups:
+    my_template:
+      type: MyGroupType
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ my_template ]
+""").assert_success()
+
+
+def test_policy_template_targets_unicode(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  類型: {}
+policy_types:
+  類型:
+    targets: [ 類型 ]
+topology_template:
+  node_templates:
+    節點:
+      type: 類型
+  policies:
+    政策:
+      type: 類型
+      targets: [ 節點 ]
+""").assert_success()
+
+
+def test_policy_template_targets_unknown(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+policy_types:
+  MyType: {}
+topology_template:
+  policies:
+    my_policy:
+      type: MyType
+      targets: [ unknown ]
+""").assert_failure()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c01e8840/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py
b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py
index dd3d443..d2fcaf4 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py
@@ -43,12 +43,18 @@ node_types:
   MyType: {}
 topology_template:
   description: a description
-  inputs: {}
-  node_templates: {}
-  relationship_templates: {}
-  groups: {}
-  policies: {}
-  outputs: {}
   substitution_mappings:
     node_type: MyType
 """).assert_success()
+
+
+def test_topology_template_fields_unicode(parser):
+    parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+  類型: {}
+topology_template:
+  description: 描述
+  substitution_mappings:
+    node_type: 類型
+""").assert_success()


Mime
View raw message