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/30 22:13:26 UTC
[10/10] incubator-ariatosca git commit: Most type tests complete
Most type tests complete
Allow some datatype-typed fields to accept nulls
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/75225e88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/75225e88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/75225e88
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 75225e88157db38ff241a94556a1695c466034dd
Parents: 8b7f660
Author: Tal Liron <ta...@gmail.com>
Authored: Wed Aug 30 17:12:18 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Wed Aug 30 17:12:18 2017 -0500
----------------------------------------------------------------------
aria/parser/presentation/fields.py | 3 +-
.../simple_v1_0/definitions.py | 22 +
.../aria_extension_tosca/simple_v1_0/misc.py | 2 +-
.../simple_v1_0/presentation/field_getters.py | 4 +-
.../aria_extension_tosca/simple_v1_0/types.py | 18 +-
.../aria_extension_tosca/simple_v1_0/data.py | 43 +-
.../templates/test_template_parameters.py | 169 +++++
.../simple_v1_0/test_imports.py | 2 +-
.../simple_v1_0/types/common/__init__.py | 14 -
.../types/common/test_type_interfaces.py | 413 ------------
.../types/common/test_type_parameters.py | 334 ----------
.../simple_v1_0/types/common/test_types.py | 152 -----
.../types/node_types/test_node_type.py | 10 -
.../node_types/test_node_type_capabilities.py | 259 ++++++--
.../test_node_type_relationship_interfaces.py | 650 +++++++++++++++++++
.../node_types/test_node_type_requirements.py | 231 ++++++-
.../simple_v1_0/types/test_artifact_type.py | 74 +++
.../simple_v1_0/types/test_capability_type.py | 83 +++
.../simple_v1_0/types/test_group_type.py | 83 +++
.../simple_v1_0/types/test_policy_type.py | 121 ++++
.../simple_v1_0/types/test_relationship_type.py | 83 +++
.../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 +++++
24 files changed, 2546 insertions(+), 979 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/aria/parser/presentation/fields.py
----------------------------------------------------------------------
diff --git a/aria/parser/presentation/fields.py b/aria/parser/presentation/fields.py
index c4b0c13..dc8894b 100644
--- a/aria/parser/presentation/fields.py
+++ b/aria/parser/presentation/fields.py
@@ -473,8 +473,7 @@ class Field(object):
# Handle get according to variant
- getter = getattr(self, '_get_{field_variant}'.format(field_variant=self.field_variant),
- None)
+ getter = getattr(self, '_get_{0}'.format(self.field_variant), None)
if getter is None:
locator = self.get_locator(raw)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/definitions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/definitions.py b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
index c1a2a66..36e0c47 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
@@ -15,7 +15,9 @@
from aria.utils.collections import FrozenDict
from aria.utils.caching import cachedmethod
+from aria.utils.formatting import safe_repr
from aria.parser import implements_specification
+from aria.parser.validation import Issue
from aria.parser.presentation import (has_fields, short_form_field, allow_unknown_fields,
primitive_field, primitive_list_field, object_field,
object_list_field, object_dict_field,
@@ -430,6 +432,16 @@ class RequirementDefinition(ExtensiblePresentation):
def _get_node_type(self, context):
return context.presentation.get_from_dict('service_template', 'node_types', self.node)
+ def _validate(self, context):
+ super(RequirementDefinition, self)._validate(context)
+ occurrences = self.occurrences
+ if (occurrences is not None) and ((occurrences.value[0] < 0) or \
+ ((occurrences.value[1] != 'UNBOUNDED') and (occurrences.value[1] < 0))):
+ context.validation.report(
+ 'requirements definition "{0}" occurrences range includes negative integers: {1}'
+ .format(self._name, safe_repr(occurrences)),
+ locator=self._locator, level=Issue.BETWEEN_TYPES)
+
@short_form_field('type')
@has_fields
@@ -518,3 +530,13 @@ class CapabilityDefinition(ExtensiblePresentation):
if container_parent is not None else None
return container_parent_capabilities.get(self._name) \
if container_parent_capabilities is not None else None
+
+ def _validate(self, context):
+ super(CapabilityDefinition, self)._validate(context)
+ occurrences = self.occurrences
+ if (occurrences is not None) and ((occurrences.value[0] < 0) or \
+ ((occurrences.value[1] != 'UNBOUNDED') and (occurrences.value[1] < 0))):
+ context.validation.report(
+ 'capability definition "{0}" occurrences range includes negative integers: {1}'
+ .format(self._name, safe_repr(occurrences)),
+ locator=self._locator, level=Issue.BETWEEN_TYPES)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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 418fe31..997a5b6 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -81,7 +81,7 @@ class MetaData(ExtensiblePresentation):
as a single-line string value.
"""
- @field_getter(data_type_class_getter(Version))
+ @field_getter(data_type_class_getter(Version, allow_null=True))
@primitive_field(str)
@implements_specification('3.9.3.5', 'tosca-simple-1.0')
def template_version(self):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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 f53a5cc..6c424a4 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
@@ -19,7 +19,7 @@ from aria.parser.exceptions import InvalidValueError
from aria.parser.presentation import NULL
-def data_type_class_getter(cls):
+def data_type_class_getter(cls, allow_null=False):
"""
Wraps the field value in a specialized data type class.
@@ -28,7 +28,7 @@ def data_type_class_getter(cls):
def getter(field, presentation, context=None):
raw = field.default_get(presentation, context)
- if (raw is None) or (raw is NULL):
+ if (raw is None) or (allow_null and (raw is NULL)):
return raw
try:
return cls(None, None, raw, None)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/extensions/aria_extension_tosca/simple_v1_0/types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py
index 2d053b0..5e4daee 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -303,7 +303,9 @@ class CapabilityType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, other_type):
- """returns True iff `other_type` is a descendant of the represented capability type"""
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if other_type is None:
return False
elif other_type._name == self._name:
@@ -315,12 +317,17 @@ class CapabilityType(ExtensiblePresentation):
return FrozenDict(get_inherited_parameter_definitions(context, self, 'properties'))
@cachedmethod
+ def _get_attributes(self, context):
+ return FrozenDict(get_inherited_parameter_definitions(context, self, 'attributes'))
+
+ @cachedmethod
def _get_valid_source_types(self, context):
return get_inherited_valid_source_types(context, self)
def _validate(self, context):
super(CapabilityType, self)._validate(context)
self._get_properties(context)
+ self._get_attributes(context)
def _dump(self, context):
self._dump_content(context, (
@@ -493,6 +500,9 @@ class RelationshipType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
@@ -625,6 +635,9 @@ class NodeType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
@@ -762,6 +775,9 @@ class GroupType(ExtensiblePresentation):
@cachedmethod
def _is_descendant(self, context, the_type):
+ """
+ Checks if ``other_type`` is our descendant (or equal to us).
+ """
if the_type is None:
return False
elif the_type._name == self._name:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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 1edb5e3..93e4d2e 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -15,9 +15,8 @@
# limitations under the License.
-NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
-NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
-NOT_A_STRING = ('123', '0.123', '[]', '{}')
+# Keywords
+
TYPE_NAMES = ('artifact', 'data', 'capability', 'interface', 'relationship', 'node', 'group',
'policy')
TYPE_NAME_PLURAL = {
@@ -36,6 +35,44 @@ TEMPLATE_NAME_SECTION = {
'group': 'groups',
'policy': 'policies'
}
+PARAMETER_SECTION_NAMES = ('properties', 'attributes')
+PARAMETER_SECTIONS = (
+ ('artifact', 'properties'),
+ ('data', 'properties'),
+ ('capability', 'properties'),
+ ('capability', 'attributes'),
+ ('interface', 'inputs'),
+ ('relationship', 'properties'),
+ ('relationship', 'attributes'),
+ ('node', 'properties'),
+ ('node', 'attributes'),
+ ('group', 'properties'),
+ ('policy', 'properties')
+)
+
+
+# Values
+
+NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
+NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
+NOT_A_STRING = ('123', '0.123', '[]', '{}')
+NOT_A_RANGE = NOT_A_LIST + (
+ '[]', '[ 1 ]', '[ 1, 2, 3 ]',
+ '[ 1, 1 ]', '[ 2, 1 ]',
+ '[ 1, a string ]', '[ a string, 1 ]',
+ '[ 1.5, 2 ]', '[ 1, 2.5 ]'
+)
+NOT_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]',)
GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'")
BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x')
STATUSES = ('supported', 'unsupported', 'experimental', 'deprecated')
+ENTRY_SCHEMA_VALUES = (
+ ('string', 'a string', 'another string'),
+ ('integer', '1', '2'),
+ ('float', '1.1', '2.2')
+)
+ENTRY_SCHEMA_VALUES_BAD = (
+ ('string', 'a string', '1'),
+ ('integer', '1', 'a string'),
+ ('float', '1.1', 'a string')
+)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
new file mode 100644
index 0000000..67731b3
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
@@ -0,0 +1,169 @@
+# -*- 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
+
+
+# Entry schema
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_map(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_map_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES
+))
+def test_node_type_parameter_list(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_success()
+
+
+@pytest.mark.parametrize('section,values', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.ENTRY_SCHEMA_VALUES_BAD
+))
+def test_node_type_parameter_list_bad(parser, section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+ {{ section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(section=section, values=values)).assert_failure()
+
+
+# Required
+
+@pytest.mark.skip(reason='fixed in ARIA-351')
+def test_node_type_property_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_failure()
+
+
+def test_node_type_property_not_required(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ required: false
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
+
+
+def test_node_type_property_required_with_default(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_property:
+ type: string
+ default: a string
+topology_template:
+ node_templates:
+ my_template:
+ type: MyType
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
index 0177ef7..0087f96 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/test_imports.py
@@ -37,7 +37,7 @@ node_types:
BAD_IMPORT = """
node_types:
MyNode:
- derived_from: not.a.node.type
+ derived_from: UnknownType
"""
@pytest.fixture(scope='session')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/75225e88/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
deleted file mode 100644
index 185451e..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_interfaces.py
+++ /dev/null
@@ -1,413 +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
-
-
-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: {}
- operation1: {}
- operation2: {}
-""", 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_good(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1: {}
- MyType2: {}
-{{ 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: {}
-{{ 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_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- 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_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- 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: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input1:
- 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
- operation1: {}
-""", 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
- operation1:
- 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
- operation1:
- 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
- operation1:
- 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
- operation1:
- 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
- operation1:
- 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_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input2:
- 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_input1:
- type: string
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- 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_input1:
- type: MyType1
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- 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_input1:
- type: MyType2
-{{ name }}_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType
- operation1:
- inputs:
- my_input1:
- type: MyType1
-""", dict(name=name)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
deleted file mode 100644
index 291abc8..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters.py
+++ /dev/null
@@ -1,334 +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
-
-
-SECTIONS = (
- ('artifact', 'properties'),
- ('data', 'properties'),
- ('capability', 'properties'),
- ('capability', 'attributes'),
- ('interface', 'inputs'),
- ('relationship', 'properties'),
- ('relationship', 'attributes'),
- ('node', 'properties'),
- ('node', 'attributes'),
- ('group', 'properties'),
- ('policy', 'properties')
-)
-SECTION_NAMES = ('properties', 'attributes')
-ENTRY_SCHEMA_VALUES = (
- ('string', 'a string', 'another string'),
- ('integer', '1', '2'),
- ('float', '1.1', '2.2')
-)
-ENTRY_SCHEMA_VALUES_BAD = (
- ('string', 'a string', '1'),
- ('integer', '1', 'a string'),
- ('float', '1.1', 'a string')
-)
-
-
-# Fields
-
-@pytest.mark.parametrize('name,parameter_section', 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', 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(SECTIONS, data.STATUSES))
-)
-def test_node_type_parameter_status_good(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', 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()
-
-
-# Entry schema
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_map(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_map_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES
-))
-def test_node_type_parameter_list(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_success()
-
-
-@pytest.mark.parametrize('section,values', itertools.product(
- SECTION_NAMES,
- ENTRY_SCHEMA_VALUES_BAD
-))
-def test_node_type_parameter_list_bad(parser, section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- {{ section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- node_templates:
- my_template:
- type: MyType
- {{ section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(section=section, values=values)).assert_failure()
-
-
-# Required
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_property_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_failure()
-
-
-def test_node_type_property_not_required(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- required: false
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-def test_node_type_property_required_with_default(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- properties:
- my_property:
- type: string
- default: a string
-topology_template:
- node_templates:
- my_template:
- type: MyType
-""").assert_success()
-
-
-# Overriding
-
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_add_default(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: string
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: string
- default: my value
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_type_override(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: MyType1
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: MyType2
-""", dict(section=section)).assert_success()
-
-
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_parameter_type_override_bad(parser, section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1:
- properties:
- field1:
- type: string
- MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
-node_types:
- MyType1:
- {{ section }}:
- my_parameter:
- type: MyType2
- MyType2:
- derived_from: MyType1
- {{ section }}:
- my_parameter:
- type: MyType1
-""", dict(section=section)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
deleted file mode 100644
index 53845c5..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/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()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py
index 4b1c446..862772a 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type.py
@@ -39,16 +39,6 @@ node_types:
""", dict(name=name, value=value)).assert_failure()
-@pytest.mark.parametrize('value', data.NOT_A_LIST)
-def test_node_type_requirements_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-node_types:
- MyType:
- requirements: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
@pytest.mark.parametrize('name', DICT_FIELD_NAMES)
def test_node_type_fields_empty(parser, name):
parser.parse_literal("""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
index 0b1abf6..345fa49 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
@@ -14,14 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import itertools
+
import pytest
from ... import data
-
-SECTION_NAMES = ('properties', 'attributes')
-
-
# Syntax
@pytest.mark.parametrize('value', data.NOT_A_DICT)
@@ -92,7 +90,7 @@ node_types:
@pytest.mark.skip(reason='fixed in ARIA-351')
-def test_node_type_capability_type_override_good(parser):
+def test_node_type_capability_type_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -134,50 +132,138 @@ node_types:
# Parameters
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_add(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_fields(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ description: a description
+ default: a value
+ status: supported
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_fields_unicode(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+node_types:
+ 類型:
+ capabilities:
+ 能力:
+ type: 類型
+ {{ parameter_section }}:
+ 參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section,value', itertools.product(
+ data.PARAMETER_SECTION_NAMES,
+ data.STATUSES
+))
+def test_node_type_capability_parameter_status(parser, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: {{ value }}
+""", dict(parameter_section=parameter_section, value=value)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_status_bad(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ status: not a status
+""", dict(parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_add(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter1:
type: string
- description: a description
- default: a value
- status: supported
node_types:
MyType:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter2:
type: string
- description: a description
- default: a value
- status: supported
-""", dict(section=section)).assert_success()
+""", dict(parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_add_default(parser, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ type: string
+ default: my value
+""", dict(parameter_section=parameter_section)).assert_success()
@pytest.mark.skip(reason='fixed in ARIA-351')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_override(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_type_override(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
- MyType1:
- properties:
- field1:
- type: string
+ MyType1: {}
MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
+ derived_from: {}
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType1
node_types:
@@ -185,30 +271,23 @@ node_types:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType2
-""", dict(section=section)).assert_success()
+""", dict(parameter_section=parameter_section)).assert_success()
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('section', SECTION_NAMES)
-def test_node_type_capability_parameter_override_bad(parser, section):
+@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
+def test_node_type_capability_parameter_type_override_bad(parser, parameter_section):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
- MyType1:
- properties:
- field1:
- type: string
+ MyType1: {}
MyType2:
- derived_from: MyType1
- properties:
- field2:
- type: integer
+ derived_from: {}
capability_types:
MyType:
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType2
node_types:
@@ -216,7 +295,101 @@ node_types:
capabilities:
my_capability:
type: MyType
- {{ section }}:
+ {{ parameter_section }}:
my_parameter:
type: MyType1
-""", dict(section=section)).assert_failure()
+""", dict(parameter_section=parameter_section)).assert_failure()
+
+
+# Valid source types
+
+def test_node_type_capability_valid_source_types(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType1:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ MyType1, MyType2 ]
+ MyType2: {}
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_node_type_capability_valid_source_types_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_capability_valid_source_types_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_valid_source_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: []
+""").assert_success()
+
+
+
+
+def test_node_type_capability_valid_source_types_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ valid_source_types: [ UnknownType ]
+""").assert_failure()
+
+
+# Occurrences
+
+@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+def test_node_type_capability_occurrences(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
new file mode 100644
index 0000000..fb50bfa
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
@@ -0,0 +1,650 @@
+# -*- 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.
+"""
+
+import pytest
+
+from ... import data
+
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_relationship_interface_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_relationship_interface_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface: {} # "type" is required
+""").assert_failure()
+
+
+def test_node_type_relationship_interface_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs: {}
+ my_operation1: {}
+ my_operation2: {}
+""").assert_success()
+
+
+def test_node_type_relationship_interface_fields_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+relationship_types:
+ 類型: {}
+interface_types:
+ 類型: {}
+node_types:
+ 類型:
+ requirements:
+ - 需求:
+ capability: 類型
+ relationship:
+ type: 類型
+ interfaces:
+ 接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+""").assert_success()
+
+
+# Type
+
+def test_node_type_relationship_interface_type_override1(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType1
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+""").assert_success()
+
+
+def test_node_type_relationship_interface_type_override2(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_type_override1_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType:
+ interfaces:
+ my_interface:
+ type: MyType2
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+""").assert_failure()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_type_override2_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType1: {}
+ MyType2:
+ derived_form: MyType1
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType2
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType1
+""").assert_failure()
+
+
+# Interface inputs
+
+def test_node_type_relationship_interface_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input2:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_inputs_type_override_same(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_inputs_type_override_derived(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_inputs_type_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
+
+
+# Operations
+
+def test_node_type_relationship_interface_operation_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation: {}
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ description: a description
+ implementation: {}
+ inputs: {}
+""").assert_success()
+
+
+# Operation implementation
+
+def test_node_type_relationship_interface_operation_implementation_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_implementation_long_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_relationship_interface_operation_implementation_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_relationship_interface_operation_dependencies_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# Operation inputs
+
+def test_node_type_relationship_interface_operation_inputs_add(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input1:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input2:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_inputs_override_same_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: string
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: string
+""").assert_success()
+
+
+def test_node_type_relationship_interface_operation_inputs_override_derived_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType1
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType2
+""").assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+def test_node_type_relationship_interface_operation_inputs_override_bad(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+data_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: MyType2
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: MyType1
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
index 5ad866f..a43a994 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
@@ -14,10 +14,109 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import pytest
-# Overriding
+from ... import data
-def test_node_type_requirement_override_change_type_good(parser):
+
+# Syntax
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT)
+def test_node_type_requirement_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: {} # "capability" is required
+""").assert_failure()
+
+
+def test_node_type_requirement_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType
+ relationship:
+ type: MyType
+ occurrences: [ 0, UNBOUNDED ]
+""").assert_success()
+
+
+def test_node_type_requirement_fields_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ 類型: {}
+relationship_types:
+ 類型: {}
+node_types:
+ 類型:
+ requirements:
+ - 需求:
+ capability: 類型
+ node: 類型
+ relationship:
+ type: 類型
+ occurrences: [ 0, UNBOUNDED ]
+""").assert_success()
+
+
+# Capability
+
+def test_node_type_requirement_capability_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement: MyType
+""").assert_success()
+
+
+def test_node_type_requirement_capability_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_capability_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: null
+""").assert_failure()
+
+
+def test_node_type_requirement_capability_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -32,5 +131,131 @@ node_types:
derived_from: MyType1
requirements:
- my_requirement:
- capability: MyType2 # you should be allowed to change the capability type to anything
+ capability: MyType2 # you are allowed to change the capability type to anything
""").assert_success()
+
+
+# Node
+
+def test_node_type_requirement_node_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_node_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: null
+""").assert_failure()
+
+
+def test_node_type_requirement_node_override(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType3
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ node: MyType4 # you are allowed to change the node type to anything
+ MyType3: {}
+ MyType4: {}
+""").assert_success()
+
+
+# Relationship
+
+def test_node_type_requirement_relationship_type_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: UnknownType
+""").assert_failure()
+
+
+def test_node_type_requirement_relationship_type_null(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: null
+""").assert_failure()
+
+
+def test_node_type_requirement_relationship_type_override(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType1: {}
+ MyType2: {}
+node_types:
+ MyType1:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType1
+ MyType2:
+ derived_from: MyType1
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType2 # you are allowed to change the relationship type to anything
+""").assert_success()
+
+
+# Occurrences
+
+@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+def test_node_type_requirement_occurrences(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ type: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/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
new file mode 100644
index 0000000..da70b6b
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_artifact_type.py
@@ -0,0 +1,74 @@
+# -*- 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
+
+
+# Syntax
+
+def test_artifact_fields(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ mime_type: a mime type
+ file_ext: [ an extension ]
+""").assert_success()
+
+
+# MIME type
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_artifact_mime_type_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ mime_type: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+# File extension
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_artifact_file_ext_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_artifact_file_ext_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: []
+""").assert_success()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_artifact_file_ext_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+artifact_types:
+ MyType:
+ file_ext: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
new file mode 100644
index 0000000..b35ea28
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_capability_type.py
@@ -0,0 +1,83 @@
+# -*- 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
+
+
+# Valid source types
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_capability_type_valid_source_types_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_capability_type_valid_source_types_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_capability_type_valid_source_types_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: []
+""").assert_success()
+
+
+def test_capability_type_valid_source_types(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+ MyType2: {}
+capability_types:
+ MyType:
+ valid_source_types: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_capability_type_valid_source_types_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+capability_types:
+ 類型:
+ valid_source_types: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_capability_type_valid_source_types_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType:
+ valid_source_types: [ UnknownType ]
+""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
new file mode 100644
index 0000000..b48e2dd
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_group_type.py
@@ -0,0 +1,83 @@
+# -*- 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
+
+
+# Members
+
+@pytest.mark.parametrize('value', data.NOT_A_LIST)
+def test_group_type_members_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_group_type_members_element_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: [ {{ value }} ]
+""", dict(value=value)).assert_failure()
+
+
+def test_group_type_members_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: []
+""").assert_success()
+
+
+def test_group_type_members(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType1: {}
+ MyType2: {}
+group_types:
+ MyType:
+ members: [ MyType1, MyType2 ]
+""").assert_success()
+
+
+def test_group_type_members_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型一: {}
+ 類型二: {}
+group_types:
+ 類型:
+ members: [ 類型一, 類型二 ]
+""").assert_success()
+
+
+def test_group_type_members_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+group_types:
+ MyType:
+ members: [ UnknownType ]
+""").assert_failure()