You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by em...@apache.org on 2017/08/31 22:27:56 UTC
incubator-ariatosca git commit: Complete type tests
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-1-parser-test-suite 75225e881 -> f29cc2ffe
Complete type tests
Improve validation of "constraints"
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/f29cc2ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/f29cc2ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/f29cc2ff
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: f29cc2ffe13cfce4658ba11aa93a5ce670c9129e
Parents: 75225e8
Author: Tal Liron <ta...@gmail.com>
Authored: Thu Aug 31 17:27:17 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Thu Aug 31 17:27:40 2017 -0500
----------------------------------------------------------------------
.travis.yml | 1 -
aria/parser/presentation/__init__.py | 14 +-
aria/parser/presentation/field_validators.py | 23 +-
.../aria_extension_tosca/simple_v1_0/misc.py | 5 +-
.../presentation/field_validators.py | 75 ++--
.../aria_extension_tosca/simple_v1_0/data.py | 16 +-
.../simple_v1_0/types/common/__init__.py | 14 +
.../types/common/test_type_interfaces.py | 439 +++++++++++++++++++
.../types/common/test_type_parameters.py | 426 ++++++++++++++++++
.../simple_v1_0/types/common/test_types.py | 155 +++++++
.../test_node_type_relationship_interfaces.py | 4 +-
.../simple_v1_0/types/test_artifact_type.py | 10 +-
.../simple_v1_0/types/test_data_type.py | 69 +++
.../simple_v1_0/types/test_interface_type.py | 282 ++++++++++++
.../simple_v1_0/types/test_type_interfaces.py | 438 ------------------
.../simple_v1_0/types/test_type_parameters.py | 165 -------
.../simple_v1_0/types/test_types.py | 152 -------
17 files changed, 1479 insertions(+), 809 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 4aafd5b..37f63a8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,6 @@ dist: precise
language: python
-dist: precise
python:
- '2.7'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/aria/parser/presentation/__init__.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/__init__.py b/aria/parser/presentation/__init__.py
index 5633e7b..aa5439c 100644
--- a/aria/parser/presentation/__init__.py
+++ b/aria/parser/presentation/__init__.py
@@ -69,6 +69,7 @@ Field validators
.. autosummary::
:nosignatures:
+ aria.parser.presentation.not_negative_validator
aria.parser.presentation.type_validator
aria.parser.presentation.list_type_validator
aria.parser.presentation.list_length_validator
@@ -93,19 +94,19 @@ Utilities
aria.parser.presentation.report_issue_for_circular_type_hierarchy
"""
-from .exceptions import PresenterException, PresenterNotFoundError
+from .exceptions import (PresenterException, PresenterNotFoundError)
from .context import PresentationContext
from .presenter import Presenter
-from .presentation import Value, PresentationBase, Presentation, AsIsPresentation
-from .source import PresenterSource, DefaultPresenterSource
-from .null import NULL, none_to_null, null_to_none
+from .presentation import (Value, PresentationBase, Presentation, AsIsPresentation)
+from .source import (PresenterSource, DefaultPresenterSource)
+from .null import (NULL, none_to_null, null_to_none)
from .fields import (Field, has_fields, short_form_field, allow_unknown_fields, primitive_field,
primitive_list_field, primitive_dict_field, primitive_dict_unknown_fields,
object_field, object_list_field, object_dict_field,
object_sequenced_list_field, object_dict_unknown_fields, field_getter,
field_setter, field_validator)
-from .field_validators import (type_validator, list_type_validator, list_length_validator,
- derived_from_validator)
+from .field_validators import (not_negative_validator, type_validator, list_type_validator,
+ list_length_validator, derived_from_validator)
from .utils import (get_locator, parse_types_dict_names, validate_primitive, validate_no_short_form,
validate_no_unknown_fields, validate_known_fields, get_parent_presentation,
report_issue_for_unknown_type, report_issue_for_unknown_parent_type,
@@ -141,6 +142,7 @@ __all__ = (
'field_getter',
'field_setter',
'field_validator',
+ 'not_negative_validator',
'type_validator',
'list_type_validator',
'list_length_validator',
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/aria/parser/presentation/field_validators.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/field_validators.py b/aria/parser/presentation/field_validators.py
index aa04913..3da01e3 100644
--- a/aria/parser/presentation/field_validators.py
+++ b/aria/parser/presentation/field_validators.py
@@ -14,12 +14,29 @@
# limitations under the License.
+from ...utils.formatting import safe_repr
from ..validation import Issue
from .utils import (parse_types_dict_names, report_issue_for_unknown_type,
report_issue_for_parent_is_self, report_issue_for_unknown_parent_type,
report_issue_for_circular_type_hierarchy)
+def not_negative_validator(field, presentation, context):
+ """
+ Makes sure that the field is not negative.
+
+ Can be used with the :func:`field_validator` decorator.
+ """
+
+ field.default_validate(presentation, context)
+ value = getattr(presentation, field.name)
+ if (value is not None) and (value < 0):
+ context.validation.report('field "{0}" is negative: {1}'
+ .format(field.name, safe_repr(value)),
+ locator=presentation._get_child_locator(field.name),
+ level=Issue.FIELD)
+
+
def type_validator(type_name, *types_dict_names):
"""
Makes sure that the field refers to an existing type defined in the root presenter.
@@ -101,8 +118,10 @@ def list_length_validator(length):
values = getattr(presentation, field.name)
if isinstance(values, list):
if len(values) != length:
- context.validation.report('field "%s" does not have exactly %d elements in "%s"'
- % (field.name, length, presentation._fullname),
+ context.validation.report('field "{0}" does not have exactly {1:d} elements in '
+ '"{2}": {3}'
+ .format(field.name, length, presentation._fullname,
+ safe_repr(values)),
locator=presentation._get_child_locator(field.name),
level=Issue.FIELD)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/extensions/aria_extension_tosca/simple_v1_0/misc.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/misc.py b/extensions/aria_extension_tosca/simple_v1_0/misc.py
index 997a5b6..01c75c5 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -21,7 +21,7 @@ from aria.parser.presentation import (AsIsPresentation, has_fields, allow_unknow
short_form_field, primitive_field, primitive_list_field,
primitive_dict_unknown_fields, object_field,
object_list_field, object_dict_field, field_getter,
- field_validator, type_validator)
+ field_validator, type_validator, not_negative_validator)
from .data_types import Version
from .modeling.data_types import (get_data_type, get_data_type_value, get_property_constraints,
@@ -258,18 +258,21 @@ class ConstraintClause(ExtensiblePresentation):
Constrains a property or parameter to a value that is in the list of declared values.
"""
+ @field_validator(not_negative_validator)
@primitive_field(int)
def length(self):
"""
Constrains the property or parameter to a value of a given length.
"""
+ @field_validator(not_negative_validator)
@primitive_field(int)
def min_length(self):
"""
Constrains the property or parameter to a value to a minimum length.
"""
+ @field_validator(not_negative_validator)
@primitive_field(int)
def max_length(self):
"""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/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 e5853d8..9c88cfe 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,8 +52,8 @@ def copy_validator(template_type_name, templates_dict_name):
else:
if copy.copy is not None:
context.validation.report(
- '"copy" field refers to a %s that itself is a copy in "%s": %s'
- % (template_type_name, presentation._fullname, safe_repr(value)),
+ '"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)
return validator_fn
@@ -84,8 +84,8 @@ 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 "%s" creates a circular value hierarchy: %s'
- % (presentation._fullname, safe_repr(value)),
+ '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)
# Can be a complex data type
@@ -135,14 +135,14 @@ 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 "%s" in "%s"'
- % (get_data_type_name(the_type), presentation._container._fullname),
+ '"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 "%s" in "%s"'
- % (get_data_type_name(the_type), presentation._container._fullname),
+ '"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,8 +201,8 @@ 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 "%s" defines constraints but does not have a primitive ancestor'
- % presentation._fullname,
+ '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,8 +220,8 @@ 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 "%s" defines properties even though it has a primitive ancestor'
- % presentation._fullname,
+ '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)
@@ -272,17 +272,18 @@ def constraint_clause_in_range_validator(field, presentation, context):
# Upper bound be coercible
upper = coerce_value(context, presentation, the_type, None, None, upper, field.name)
- # Second "in_range" value must be greater than first
+ # 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 "%s": %s <= %s'
- % (presentation._container._fullname, safe_repr(lower), safe_repr(upper)),
+ ' 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 "%s" is not a list of exactly 2 elements in "%s"'
- % (field.name, presentation._fullname),
+ '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)
@@ -325,8 +326,8 @@ def constraint_clause_pattern_validator(field, presentation, context):
re.compile(value)
except re.error as e:
context.validation.report(
- 'constraint "%s" is not a valid regular expression in "%s"'
- % (field.name, presentation._fullname),
+ '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)
@@ -379,21 +380,21 @@ 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(
- '"%s" refers to a capability type even though "node" has a value in "%s"'
- % (presentation._name, presentation._container._fullname),
+ '"{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 "%s" refers to an unknown capability definition name or capability'
- ' type in "%s": %s'
- % (presentation._name, presentation._container._fullname, safe_repr(value)),
+ 'requirement "{0}" refers to an unknown capability definition name or 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)
else:
context.validation.report(
- 'requirement "%s" refers to an unknown capability type in "%s": %s'
- % (presentation._name, presentation._container._fullname, safe_repr(value)),
+ '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)
@@ -412,9 +413,9 @@ def node_filter_validator(field, presentation, context):
_, node_type_variant = presentation._get_node(context)
if node_type_variant != 'node_type':
context.validation.report(
- 'requirement "%s" has a node filter even though "node" does not refer to a node'
- ' type in "%s"'
- % (presentation._fullname, presentation._container._fullname),
+ 'requirement "{0}" has a node filter even though "node" does not refer to a node'
+ ' type in "{1}"'
+ .format(presentation._fullname, presentation._container._fullname),
locator=presentation._locator, level=Issue.BETWEEN_FIELDS)
@@ -520,8 +521,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 "%s": %s'
- % (presentation._name, safe_repr(value)),
+ ' declared in the policy type in "{0}": {1}'
+ .format(presentation._name, safe_repr(value)),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
@@ -547,8 +548,8 @@ 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 "%s": %s'
- % (node_type._name, name),
+ 'node filter refers to an unknown property definition in "{0}": {1}'
+ .format(node_type._name, name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
@@ -578,11 +579,11 @@ def node_filter_capabilities_validator(field, presentation, context):
if property_name not in capability_properties:
context.validation.report(
'node filter refers to an unknown capability definition'
- ' property in "%s": %s'
- % (node_type._name, property_name),
+ ' 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 "%s": %s'
- % (node_type._name, name),
+ '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/f29cc2ff/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 93e4d2e..d428668 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -29,6 +29,7 @@ TYPE_NAME_PLURAL = {
'group': 'groups',
'policy': 'policies'
}
+PRIMITIVE_TYPE_NAMES = ('string', 'integer', 'float', 'boolean')
TEMPLATE_NAMES = ('node', 'group', 'policy')
TEMPLATE_NAME_SECTION = {
'node': 'node_templates',
@@ -49,7 +50,20 @@ PARAMETER_SECTIONS = (
('group', 'properties'),
('policy', 'properties')
)
-
+PARAMETER_WITH_CONSTRAINTS_SECTIONS = (
+ ('artifact', 'properties'),
+ ('data', 'properties'),
+ ('capability', 'properties'),
+ ('interface', 'inputs'),
+ ('relationship', 'properties'),
+ ('node', 'properties'),
+ ('group', 'properties'),
+ ('policy', 'properties')
+)
+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')
# Values
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
@@ -0,0 +1,14 @@
+# 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/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
new file mode 100644
index 0000000..50f0c2e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
@@ -0,0 +1,439 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+"""
+Developer note: make sure that these tests mirror those in:
+ test_interface_type.py,
+ test_node_type_relationship_interfaces.py.
+"""
+
+import itertools
+
+import pytest
+
+from ... import data
+
+
+TYPE_NAMES = ('node', 'relationship', 'group')
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_interface_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface: {} # "type" is required
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ my_operation1: {}
+ my_operation2: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ 類型: {}
+{{ name }}_types:
+ 類型:
+ interfaces:
+ 接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+""", dict(name=name)).assert_success()
+
+
+# Type
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+{{ name }}_types:
+ MyType1:
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ interfaces:
+ my_interface:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_same(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_derived(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_inputs_type_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType1
+""", dict(name=name)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ description: a description
+ implementation: {}
+ inputs: {}
+""", dict(name=name)).assert_success()
+
+
+# Operation implementation
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_short_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_implementation_long_form(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_add(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_same_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_derived_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', TYPE_NAMES)
+def test_type_interface_operation_inputs_override_bad(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+{{ name }}_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
new file mode 100644
index 0000000..82da830
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
@@ -0,0 +1,426 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import itertools
+
+import pytest
+
+from ... import data
+
+
+# Fields
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_fields(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_fields_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Status
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(data.PARAMETER_SECTIONS, data.STATUSES))
+)
+def test_type_parameter_status(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: {{ value }}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_status_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: not a status
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Constraints
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(data.PARAMETER_WITH_CONSTRAINTS_SECTIONS, data.NOT_A_LIST))
+)
+def test_type_parameter_constraints_wrong_yaml_type(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints: {{ value }}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
+def test_type_parameter_constraints_empty(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints: []
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_VALUE))
+)
+def test_type_parameter_constraints_with_value(parser, name, parameter_section, constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{%- if name != 'data' %}
+{{ name }}_types:
+{%- endif %}
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}: {my_field: a string}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_VALUE_LIST))
+)
+def test_type_parameter_constraints_with_value_list(parser, name, parameter_section, constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{%- if name != 'data' %}
+{{ name }}_types:
+{%- endif %}
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string one}
+ - {my_field: string two}
+ - {my_field: string three}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE))
+)
+def test_type_parameter_constraints_with_value_range(parser, name, parameter_section, constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{%- if name != 'data' %}
+{{ name }}_types:
+{%- endif %}
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string a}
+ - {my_field: string b}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE))
+)
+def test_type_parameter_constraints_with_value_range_too_many(parser, name, parameter_section,
+ constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{%- if name != 'data' %}
+{{ name }}_types:
+{%- endif %}
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string a}
+ - {my_field: string b}
+ - {my_field: string c}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_VALUE_RANGE))
+)
+def test_type_parameter_constraints_with_value_range_invalid(parser, name, parameter_section,
+ constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyDataType:
+ properties:
+ my_field:
+ type: string
+{%- if name != 'data' %}
+{{ name }}_types:
+{%- endif %}
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}:
+ - {my_field: string b}
+ - {my_field: string a}
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
+def test_type_parameter_constraints_pattern(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints:
+ - pattern: ^pattern$
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
+def test_type_parameter_constraints_pattern_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ constraints:
+ - pattern: ^模式$
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
+def test_type_parameter_constraints_pattern_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints:
+ - pattern: (
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_NON_NEGATIVE_INT))
+)
+def test_type_parameter_constraints_with_integer(parser, name, parameter_section, constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: 1
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,constraint',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ data.CONSTRAINTS_WITH_NON_NEGATIVE_INT))
+)
+def test_type_parameter_constraints_with_integer_bad(parser, name, parameter_section, constraint):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: -1
+""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
+
+
+# Overriding
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_add(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter2:
+ type: string
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_add_default(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ default: my value
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_type_override(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType2
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
+def test_type_parameter_type_override_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+{{ name }}_types:
+ MyType1:
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ {{ parameter_section }}:
+ my_parameter:
+ type: MyType1
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
new file mode 100644
index 0000000..9e103ef
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
@@ -0,0 +1,155 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import itertools
+
+import pytest
+
+from ... import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_DICT
+))
+def test_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.NOT_A_STRING
+))
+def test_type_derived_from_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+# Derived from
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: UnknownType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_null(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: null
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_self(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ derived_from: MyType
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_circular(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1:
+ derived_from: MyType3
+ MyType2:
+ derived_from: MyType1
+ MyType3:
+ derived_from: MyType2
+""", dict(name=name)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from_root(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+""", dict(name=name)).assert_success()
+
+
+# Common fields
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+ version: 1.0.0
+ description: a description
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_fields_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型一: {}
+ 類型二:
+ derived_from: 類型一
+ version: 1.0.0.詠嘆調-10
+ description: 描述
+""", dict(name=name)).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.BAD_VERSIONS
+))
+def test_type_bad_version(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
index fb50bfa..358d78e 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
@@ -15,7 +15,9 @@
# limitations under the License.
"""
-Developer note: make sure that these tests mirror those in test_type_interfaces.py.
+Developer note: make sure that these tests mirror those in:
+ test_interface_type.py,
+ test_type_interfaces.py.
"""
import pytest
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
index da70b6b..1e5e1e0 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
@@ -21,7 +21,7 @@ from .. import data
# Syntax
-def test_artifact_fields(parser):
+def test_artifact_type_fields(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
artifact_types:
@@ -34,7 +34,7 @@ artifact_types:
# MIME type
@pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_artifact_mime_type_wrong_yaml_type(parser, value):
+def test_artifact_type_mime_type_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
artifact_types:
@@ -46,7 +46,7 @@ artifact_types:
# File extension
@pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_artifact_file_ext_wrong_yaml_type(parser, value):
+def test_artifact_type_file_ext_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
artifact_types:
@@ -55,7 +55,7 @@ artifact_types:
""", dict(value=value)).assert_failure()
-def test_artifact_file_ext_empty(parser):
+def test_artifact_type_file_ext_empty(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
artifact_types:
@@ -65,7 +65,7 @@ artifact_types:
@pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_artifact_file_ext_element_wrong_yaml_type(parser, value):
+def test_artifact_type_file_ext_element_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
artifact_types:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
new file mode 100644
index 0000000..539d4f8
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_data_type.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import itertools
+
+import pytest
+
+from .. import data
+
+
+# Derived from primitive
+
+@pytest.mark.parametrize('name', data.PRIMITIVE_TYPE_NAMES)
+def test_data_type_derived_from_primitive(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ derived_from: {{ name }}
+""", dict(name=name)).assert_success()
+
+
+# Constraints
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.PRIMITIVE_TYPE_NAMES,
+ data.NOT_A_LIST
+))
+def test_data_type_constraints_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ derived_from: string
+ constraints: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.PRIMITIVE_TYPE_NAMES)
+def test_data_type_constraints_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ derived_from: string
+ constraints: []
+""", dict(name=name)).assert_success()
+
+
+def test_data_type_constraints_not_primitive(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ constraints: [] # can't have constraints if not a primitive
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
new file mode 100644
index 0000000..9d41f97
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
@@ -0,0 +1,282 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+"""
+Developer note: make sure that these tests mirror those in:
+ test_type_interfaces.py,
+ test_node_type_relationship_interfaces.py.
+"""
+
+import pytest
+
+from .. import data
+
+
+# Fields
+
+def test_interface_type_fields_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ 類型:
+ inputs:
+ 輸入:
+ type: string
+ 手術:
+ description: 描述
+ implementation:
+ primary: 履行
+ dependencies:
+ - 依賴
+ inputs:
+ 輸入:
+ type: string
+""").assert_success()
+
+
+# Interface inputs
+
+def test_interface_type_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ inputs:
+ my_input1:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ my_input2:
+ type: string
+""").assert_success()
+
+
+def test_interface_type_inputs_type_override_same(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ inputs:
+ my_input:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_interface_type_inputs_type_override_derived(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType1:
+ inputs:
+ my_input:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_interface_type_inputs_type_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType1:
+ inputs:
+ my_input:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
+
+
+# Operations
+
+def test_interface_type_operation_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation: {}
+""").assert_success()
+
+
+def test_interface_type_operation_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation:
+ description: a description
+ implementation: {}
+ inputs: {}
+""").assert_success()
+
+
+# Operation implementation
+
+def test_interface_type_operation_implementation_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation:
+ implementation: an implementation
+""").assert_success()
+
+
+def test_interface_type_operation_implementation_long_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_interface_type_operation_implementation_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_interface_type_operation_dependencies_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# Operation inputs
+
+def test_interface_type_operation_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_interface_type_operation_inputs_override_same_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType1:
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+ MyType2:
+ derived_from: MyType1
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_interface_type_operation_inputs_override_derived_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType1:
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_interface_type_operation_inputs_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType1:
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
deleted file mode 100644
index c4283bd..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py
+++ /dev/null
@@ -1,438 +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.
-
-
-"""
-Developer note: make sure that these tests mirror those in
-test_node_type_relationship_interfaces.py.
-"""
-
-import itertools
-
-import pytest
-
-from .. import data
-
-
-TYPE_NAMES = ('node', 'relationship', 'group')
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_interface_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface: {} # "type" is required
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs: {}
- my_operation1: {}
- my_operation2: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_fields_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- 類型: {}
-{{ name }}_types:
- 類型:
- interfaces:
- 接口:
- type: 類型
- 手術:
- implementation: 履行
-""", dict(name=name)).assert_success()
-
-
-# Type
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2:
- derived_form: MyType1
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType1
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2:
- derived_form: MyType1
-{{ name }}_types:
- MyType1:
- interfaces:
- my_interface:
- type: MyType2
- MyType2:
- derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Interface inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input2:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_same(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_derived(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: MyType1
-""", dict(name=name)).assert_failure()
-
-
-# Operations
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- description: a description
- implementation: {}
- inputs: {}
-""", dict(name=name)).assert_success()
-
-
-# Operation implementation
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_short_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation: an implementation
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_long_form(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - a dependency
- - another dependency
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Operation inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_add(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_same_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- inputs:
- my_input:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: string
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_derived_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: MyType2
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_override_bad(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: MyType1
-""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
deleted file mode 100644
index bb65bbd..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py
+++ /dev/null
@@ -1,165 +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.
-
-import itertools
-
-import pytest
-
-from .. import data
-
-
-# Fields
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_fields(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- description: a description
- default: a value
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_fields_unicode(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- 參數:
- type: string
- description: 描述
- default: 值
- status: supported
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-# Status
-
-@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(data.PARAMETER_SECTIONS, data.STATUSES))
-)
-def test_node_type_parameter_status(parser, name, parameter_section, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: {{ value }}
-""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_status_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: not a status
-""", dict(name=name, parameter_section=parameter_section)).assert_failure()
-
-
-# Overriding
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_add(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- {{ parameter_section }}:
- my_parameter1:
- type: string
- MyType2:
- derived_from: MyType1
- {{ parameter_section }}:
- my_parameter2:
- type: string
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_add_default(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: string
- MyType2:
- derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: string
- default: my value
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_type_override(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-{{ name }}_types:
- MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: MyType1
- MyType2:
- derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: MyType2
-""", dict(name=name, parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_node_type_parameter_type_override_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-{{ name }}_types:
- MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: MyType2
- MyType2:
- derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: MyType1
-""", dict(name=name, parameter_section=parameter_section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f29cc2ff/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
deleted file mode 100644
index 8e2f26f..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py
+++ /dev/null
@@ -1,152 +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.
-
-import itertools
-
-import pytest
-
-from .. import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-""", dict(name=name)).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.NOT_A_STRING
-))
-def test_type_derived_from_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: {{ value }}
-""", dict(name=name, value=value)).assert_failure()
-
-
-# Derivation
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_unknown(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: UnknownType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_null(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: null
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_self(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: MyType
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_circular(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType1:
- derived_from: MyType3
- MyType2:
- derived_from: MyType1
- MyType3:
- derived_from: MyType2
-""", dict(name=name)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_root(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0
- description: a description
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型:
- derived_from: tosca.{{ plural }}.Root
- version: 1.0.0.詠嘆調-10
- description: 描述
-""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TYPE_NAMES,
- data.BAD_VERSIONS
-))
-def test_type_bad_version(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- version: {{ value }}
-""", dict(name=name, value=value)).assert_failure()