Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-1-parser-test-suite 7d55c93a2 -> ec66be48f (forced update)
More fixes Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ec66be48 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ec66be48 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ec66be48 Branch: refs/heads/ARIA-1-parser-test-suite Commit: ec66be48fc25cf0d56d7af8e3c4509a2e98dc372 Parents: f4f0985 Author: Tal Liron <[email protected]> Authored: Tue Oct 24 14:04:40 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Fri Oct 27 18:53:44 2017 -0500 ---------------------------------------------------------------------- .../simple_v1_0/definitions.py | 5 +- .../simple_v1_0/modeling/capabilities.py | 50 +++++++++++++----- .../simple_v1_0/modeling/interfaces.py | 40 +++++++++------ .../simple_v1_0/modeling/parameters.py | 33 +++++++----- .../simple_v1_0/modeling/requirements.py | 53 ++++++++++++++++---- .../aria_extension_tosca/simple_v1_0/types.py | 3 +- requirements.in | 43 ++++++++-------- requirements.txt | 18 ++++--- .../functions/test_function_get_artifact.py | 2 +- .../common/test_template_parameters.py | 11 ++-- .../test_template_parameters_properties.py | 1 - .../test_node_template_requirements.py | 13 ++--- .../simple_v1_0/test_imports.py | 4 +- .../types/common/test_type_interfaces.py | 17 ++++--- .../types/common/test_type_parameters.py | 4 +- .../common/test_type_parameters_inheritance.py | 18 ++++--- .../node_type/test_node_type_capabilities.py | 7 ++- .../test_node_type_relationship_interfaces.py | 42 +--------------- tests/requirements.txt | 10 ++-- 19 files changed, 206 insertions(+), 168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/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 02794e8..a7e2806 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py +++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py @@ -331,9 +331,8 @@ class InterfaceDefinition(ExtensiblePresentation): def _validate(self, context): super(InterfaceDefinition, self)._validate(context) - if self.operations: - for operation in self.operations.itervalues(): # pylint: disable=no-member - operation._validate(context) + self._get_inputs(context) + self._get_operations(context) @short_form_field('type') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py index ca32dde..bf6636b 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py @@ -139,6 +139,15 @@ def get_template_capabilities(context, presentation): if values: capability_assignment._raw['properties'] = values capability_assignment._reset_method_cache() + + # Assign attributes + values = get_assigned_and_defined_parameter_values(context, + our_capability_assignment, + 'attribute') + + if values: + capability_assignment._raw['attributes'] = values + capability_assignment._reset_method_cache() else: context.validation.report( u'capability "{0}" not declared at node type "{1}" in "{2}"' @@ -161,29 +170,38 @@ def convert_capability_from_definition_to_assignment(context, presentation, cont if properties is not None: raw['properties'] = convert_parameter_definitions_to_values(context, properties) - # TODO attributes + attributes = presentation.attributes + if attributes is not None: + raw['attributes'] = convert_parameter_definitions_to_values(context, attributes) return CapabilityAssignment(name=presentation._name, raw=raw, container=container) def merge_capability_definition(context, presentation, capability_definition, from_capability_definition): - raw_properties = OrderedDict() - capability_definition._raw['type'] = from_capability_definition.type - # Merge properties from type - from_property_defintions = from_capability_definition.properties - merge_raw_parameter_definitions(context, presentation, raw_properties, from_property_defintions, - 'properties') + raw_properties = OrderedDict() + raw_attributes = OrderedDict() - # Merge our properties + # Merge parameters from type merge_raw_parameter_definitions(context, presentation, raw_properties, capability_definition.properties, 'properties') + merge_raw_parameter_definitions(context, presentation, raw_attributes, + capability_definition.attributes, 'attributes') + + # Merge our parameters + merge_raw_parameter_definitions(context, presentation, raw_properties, + from_capability_definition.properties, 'properties') + merge_raw_parameter_definitions(context, presentation, raw_attributes, + from_capability_definition.attributes, 'attributes') if raw_properties: capability_definition._raw['properties'] = raw_properties capability_definition._reset_method_cache() + if raw_attributes: + capability_definition._raw['attributes'] = raw_attributes + capability_definition._reset_method_cache() # Merge occurrences occurrences = from_capability_definition._raw.get('occurrences') @@ -194,23 +212,31 @@ def merge_capability_definition(context, presentation, capability_definition, def merge_capability_definition_from_type(context, presentation, capability_definition): """ - Merge ``properties`` and ``valid_source_types`` from the node type's capability definition - over those taken from the parent node type. + Merge ``properties``, ``attributes``, and ``valid_source_types`` from the node type's capability + definition over those taken from the parent node type. """ raw_properties = OrderedDict() + raw_attributes = OrderedDict() - # Merge properties from parent + # Merge parameters from parent the_type = capability_definition._get_type(context) type_property_defintions = the_type._get_properties(context) + type_attribute_defintions = the_type._get_attributes(context) merge_raw_parameter_definitions(context, presentation, raw_properties, type_property_defintions, 'properties') + merge_raw_parameter_definitions(context, presentation, raw_attributes, + type_attribute_defintions, 'attributes') - # Merge our properties (might override definitions in parent) + # Merge our parameters (might override definitions in parent) merge_raw_parameter_definitions(context, presentation, raw_properties, capability_definition.properties, 'properties') + merge_raw_parameter_definitions(context, presentation, raw_attributes, + capability_definition.attributes, 'attributes') if raw_properties: capability_definition._raw['properties'] = raw_properties + if raw_attributes: + capability_definition._raw['attributes'] = raw_attributes # Override valid_source_types if capability_definition._raw.get('valid_source_types') is None: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py index d7538c1..7580ef3 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py @@ -18,6 +18,7 @@ from aria.parser.presentation import get_locator from aria.parser.validation import Issue from .parameters import (coerce_parameter_value, convert_parameter_definitions_to_values) +from .data_types import (get_type_by_name, get_primitive_data_type) # @@ -156,7 +157,7 @@ def get_template_interfaces(context, presentation, type_name): interface_definitions = the_type._get_interfaces(context) if the_type is not None else None # Copy over interfaces from the type (will initialize inputs with default values) - if interface_definitions is not None: + if interface_definitions: for interface_name, interface_definition in interface_definitions.iteritems(): # Note that in the case of a RelationshipTemplate, we will already have the values as # InterfaceAssignment. It will not be converted, just cloned. @@ -302,23 +303,28 @@ def merge_interface(context, presentation, interface_assignment, our_interface_a def merge_raw_input_definition(context, the_raw_input, our_input, interface_name, operation_name, presentation, type_name): # Check if we changed the type - # TODO: allow a sub-type? - input_type1 = the_raw_input.get('type') - input_type2 = our_input.type - if input_type1 != input_type2: + input_type1_name = the_raw_input.get('type') + input_type1 = get_type_by_name(context, input_type1_name, 'data_types') + if input_type1 is None: + input_type1 = get_primitive_data_type(input_type1_name) + input_type2 = our_input._get_type(context) + if input_type1 is not input_type2 and \ + (not hasattr(input_type1, '_is_descendant') or \ + not input_type1._is_descendant(context, input_type2)): if operation_name is not None: context.validation.report( - u'interface {0} "{1}" changes operation input "{2}.{3}" type from "{4}" to "{5}" ' - u'in "{6}"' - .format(type_name, interface_name, operation_name, our_input._name, input_type1, - input_type2, presentation._fullname), - locator=input_type2._locator, level=Issue.BETWEEN_TYPES) + u'type "{0}" is not a descendant of overridden type "{1}" for input "{2}" of ' + u'operation {3} "{4}.{5}" in {6}' + .format(our_input.type, input_type1_name, our_input._name, type_name, + interface_name, operation_name, presentation._fullname), + locator=our_input._locator, level=Issue.BETWEEN_TYPES) else: context.validation.report( - u'interface {0} "{1}" changes input "{2}" type from "{3}" to "{4}" in "{5}"' - .format(type_name, interface_name, our_input._name, input_type1, input_type2, - presentation._fullname), - locator=input_type2._locator, level=Issue.BETWEEN_TYPES) + u'type "{0}" is not a descendant of overridden type "{1}" for input "{2}" of ' + u'interface {3} "{4}" in {5}' + .format(our_input.type, input_type1_name, our_input._name, type_name, + interface_name, presentation._fullname), + locator=our_input._locator, level=Issue.BETWEEN_TYPES) # Merge merge(the_raw_input, our_input._raw) @@ -493,7 +499,11 @@ def validate_required_inputs(context, presentation, assignment, definition, orig # (as opposed to topology template and workflow inputs) is done only in the parsing stage. # This reasoning follows the TOSCA spirit, where anything that is declared as required in the # type, must be assigned in the corresponding template. - input_definitions = definition.inputs + + # Note: InterfaceDefinition need _get_inputs, but OperationDefinition doesn't + input_definitions = definition._get_inputs(context) \ + if hasattr(definition, '_get_inputs') \ + else definition.inputs if input_definitions: for input_name, input_definition in input_definitions.iteritems(): if input_definition.required: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py index 6a0af90..c3a1800 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py @@ -147,9 +147,19 @@ def validate_required_values(context, presentation, values, definitions): if not definitions: return + + def has_value(name): + if values is None: + return False + value = values.get(name) + if value is None: + return False + if isinstance(value, Value) and (value.value is None): + return False + return True + for name, definition in definitions.iteritems(): - if getattr(definition, 'required', False) \ - and ((values is None) or (values.get(name) is None)): + if getattr(definition, 'required', False) and not has_value(name): context.validation.report(u'required property "{0}" is not assigned a value in "{1}"' .format(name, presentation._fullname), locator=presentation._get_child_locator('properties'), @@ -166,14 +176,14 @@ def merge_raw_parameter_definition(context, presentation, raw_property_definitio our_property_definition._reset_method_cache() type2 = our_property_definition._get_type(context) - if type1 != type2: - if not hasattr(type1, '_is_descendant') or not type1._is_descendant(context, type2): - context.validation.report( - u'property definition type "{0}" is not a descendant of overridden ' - u'property definition type "{1}"' \ - .format(type1_name, type2._name), - locator=presentation._get_child_locator(field_name, property_name), - level=Issue.BETWEEN_TYPES) + if (type1 is not type2) and \ + (not hasattr(type1, '_is_descendant') or not type1._is_descendant(context, type2)): + context.validation.report( + u'property definition type "{0}" is not a descendant of overridden ' + u'property definition type "{1}"' \ + .format(our_property_definition.type, type1_name), + locator=presentation._get_child_locator(field_name, property_name), + level=Issue.BETWEEN_TYPES) merge(raw_property_definition, our_property_definition._raw) @@ -225,6 +235,5 @@ def coerce_parameter_value(context, presentation, definition, value, aspect=None def convert_parameter_definitions_to_values(context, definitions): values = OrderedDict() for name, definition in definitions.iteritems(): - default = definition.default - values[name] = coerce_parameter_value(context, definition, definition, default) + values[name] = coerce_parameter_value(context, definition, definition, definition.default) return values http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py index bf1088b..094ea13 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py @@ -103,7 +103,8 @@ def get_template_requirements(context, presentation): None, presentation) validate_requirement_assignment(context, presentation, requirement_assignment, relationship_property_definitions, - relationship_interface_definitions) + relationship_interface_definitions, + requirement_definition) requirement_assignments.append((requirement_name, requirement_assignment)) elif actual_occurrences > 1: context.validation.report( @@ -254,7 +255,8 @@ def add_requirement_assignments(context, presentation, requirement_assignments, or our_requirement_assignment, requirement_assignment, relationship_property_definitions, - relationship_interface_definitions) + relationship_interface_definitions, + requirement_definition) requirement_assignments.append((requirement_name, requirement_assignment)) else: context.validation.report(u'requirement "{0}" not declared at node type "{1}" in "{2}"' @@ -279,7 +281,7 @@ def merge_requirement_assignment(context, relationship_property_definitions, requirement._raw['node_filter'] = deepcopy_with_locators(our_node_filter._raw) our_relationship = our_requirement.relationship # RelationshipAssignment - if (our_relationship is not None) and (our_relationship.type is None): + if our_relationship is not None: # Make sure we have a dict if 'relationship' not in requirement._raw: requirement._raw['relationship'] = OrderedDict() @@ -292,7 +294,8 @@ def merge_requirement_assignment(context, relationship_property_definitions, def merge_requirement_assignment_relationship(context, presentation, property_definitions, interface_definitions, requirement, our_relationship): - our_relationship_properties = our_relationship._raw.get('properties') + our_relationship_properties = our_relationship._raw.get('properties') \ + if isinstance(our_relationship._raw, dict) else None if our_relationship_properties: # Make sure we have a dict if 'properties' not in requirement._raw['relationship']: @@ -340,19 +343,49 @@ def merge_requirement_assignment_relationship(context, presentation, property_de def validate_requirement_assignment(context, presentation, requirement_assignment, relationship_property_definitions, - relationship_interface_definitions): + relationship_interface_definitions, requirement_definition): + # Validate node + definition_node_type = requirement_definition._get_node_type(context) + assignment_node_type, node_variant = requirement_assignment._get_node(context) + if node_variant == 'node_template': + assignment_node_type = assignment_node_type._get_type(context) + if (assignment_node_type is not None) and (definition_node_type is not None) and \ + (assignment_node_type is not definition_node_type) and \ + (not definition_node_type._is_descendant(context, assignment_node_type)): + context.validation.report( + u'requirement assignment node "{0}" is not derived from node type "{1}" of requirement ' + u'definition in {2}' + .format(requirement_assignment.node, requirement_definition.node, + presentation._container._fullname), + locator=presentation._locator, level=Issue.BETWEEN_TYPES) + + # Validate capability + definition_capability_type = requirement_definition._get_capability_type(context) + assignment_capability_type, capability_variant = requirement_assignment._get_capability(context) + if capability_variant == 'capability_assignment': + assignment_capability_type = assignment_capability_type._get_type(context) + if (assignment_capability_type is not None) and (definition_capability_type is not None) and \ + (assignment_capability_type is not definition_capability_type) and \ + (not definition_capability_type._is_descendant(context, assignment_capability_type)): + context.validation.report( + u'requirement assignment capability "{0}" is not derived from capability type "{1}" of ' + u'requirement definition in {2}' + .format(requirement_assignment.capability, requirement_definition.capability, + presentation._container._fullname), + locator=presentation._locator, level=Issue.BETWEEN_TYPES) + relationship = requirement_assignment.relationship - if relationship is None: - return - validate_required_values(context, presentation, relationship.properties, - relationship_property_definitions) + values = OrderedDict((name, prop.value) + for name, prop in relationship.properties.iteritems()) \ + if (relationship and relationship.properties) else {} + validate_required_values(context, presentation, values, relationship_property_definitions) if relationship_interface_definitions: for interface_name, relationship_interface_definition \ in relationship_interface_definitions.iteritems(): interface_assignment = relationship.interfaces.get(interface_name) \ - if relationship.interfaces is not None else None + if (relationship and relationship.interfaces) else None validate_required_inputs(context, presentation, interface_assignment, relationship_interface_definition, None, interface_name) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/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 060c38c..8ab7b07 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/types.py +++ b/extensions/aria_extension_tosca/simple_v1_0/types.py @@ -428,8 +428,7 @@ class InterfaceType(ExtensiblePresentation): def _validate(self, context): super(InterfaceType, self)._validate(context) self._get_inputs(context) - for operation in self.operations.itervalues(): # pylint: disable=no-member - operation._validate(context) + self._get_operations(context) def _dump(self, context): self._dump_content(context, ( http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/requirements.in ---------------------------------------------------------------------- diff --git a/requirements.in b/requirements.in index caeaaf3..6398302 100644 --- a/requirements.in +++ b/requirements.in @@ -13,28 +13,27 @@ # In order to create the requirements.txt file, execute # pip-compile --output-file requirements.txt requirements.in (pip-tools package is needed). -requests>=2.3.0, <2.14.0 -networkx>=1.9, <1.10 # version 1.10 dropped support for Python 2.6 -retrying>=1.3.0, <1.4.0 +backports.shutil_get_terminal_size>=1, <2 blinker>1.3, <1.5 -jsonpickle>0.9.0, <=0.9.4 -ruamel.yaml>=0.11.12, <0.12.0 # version 0.12.0 dropped support for Python 2.6 -Jinja2>=2.8, <3.0 -shortuuid>=0.5, <0.6 -CacheControl[filecache]>=0.11.0, <0.13 -SQLAlchemy>=1.1.0, <1.2 # version 1.2 dropped support for Python 2.6 -wagon==0.6.0 -wheel==0.29.0 # version 0.30.0 dropped support for Python 2.6 -bottle>=0.12.0, <0.13 -setuptools>=35.0.0, <36.0.0 -click>=6.0, < 7.0 -colorama>=0.3.7, <=0.3.9 -PrettyTable>=0.7,<0.8 -click_didyoumean==0.0.3 -backports.shutil_get_terminal_size==1.0.0 -logutils==0.3.4.1 -psutil>=5.2.2, <6.0.0 +bottle>=0.12, <0.13 +CacheControl[filecache]>=0.11, <0.13 +click>=6, <7 +click_didyoumean>=0.0.3, <0.1 +colorama>=0.3, <=0.4 importlib ; python_version < '2.7' +Jinja2>=2.8, <2.10 +jsonpickle>0.9, <=0.10 +logutils>=0.3, <0.4 +networkx>=1.9, <1.10 # version 1.10 dropped support for Python 2.6 ordereddict ; python_version < '2.7' -total-ordering ; python_version < '2.7' # only one version on PyPI -wheel<=0.29.0 ; python_version < '2.7' +PrettyTable>=0.7,<0.8 +psutil>=5.2, <5.5 +requests>=2.3, <2.19 +retrying>=1.3, <1.4 +ruamel.yaml>=0.11.12, <0.12.0 # version 0.12.0 dropped support for Python 2.6 +setuptools>=35, <37 +shortuuid>=0.5, <0.6 +SQLAlchemy>=1.1, <1.2 # version 1.2 dropped support for Python 2.6 +total-ordering>=0.1, <0.2 ; python_version < '2.7' +wagon>=0.6, <0.7 +wheel>=0.29, <0.30 # version 0.30.0 dropped support for Python 2.6 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/requirements.txt ---------------------------------------------------------------------- diff --git a/requirements.txt b/requirements.txt index cbb015a..f37ccf9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,26 +4,29 @@ # # pip-compile --output-file ./requirements.txt ./requirements.in # -backports.shutil_get_terminal_size==1.0.0 +backports.shutil-get-terminal-size==1.0.0 blinker==1.4 bottle==0.12.13 cachecontrol[filecache]==0.12.3 +certifi==2017.7.27.1 # via requests +chardet==3.0.4 # via requests +click-didyoumean==0.0.3 click==6.7 -click_didyoumean==0.0.3 colorama==0.3.9 decorator==4.1.2 # via networkx +idna==2.6 # via requests importlib==1.0.4 ; python_version < "2.7" jinja2==2.9.6 -jsonpickle==0.9.4 +jsonpickle==0.9.5 lockfile==0.12.2 # via cachecontrol -logutils==0.3.4.1 +logutils==0.3.5 markupsafe==1.0 # via jinja2 msgpack-python==0.4.8 # via cachecontrol networkx==1.9.1 ordereddict==1.1 ; python_version < "2.7" prettytable==0.7.2 psutil==5.4.0 -requests==2.13.0 +requests==2.18.4 retrying==1.3.3 ruamel.ordereddict==0.4.13 # via ruamel.yaml ruamel.yaml==0.11.15 @@ -31,8 +34,9 @@ shortuuid==0.5.0 six==1.11.0 # via retrying sqlalchemy==1.1.14 total-ordering==0.1.0 ; python_version < "2.7" -wagon==0.6.0 -wheel==0.29.0 ; python_version < "2.7" +urllib3==1.22 # via requests +wagon==0.6.1 +wheel==0.29.0 # The following packages are considered to be unsafe in a requirements file: # setuptools http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py index 11be88a..6fa1a3c 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py @@ -61,7 +61,7 @@ topology_template: """).assert_success() [email protected](reason='not implemented') [email protected](reason='not yet implemented') def test_functions_get_artifact_unknown(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py index 6258a92..c5fcd30 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py @@ -85,7 +85,7 @@ INTERFACE_MACROS = """ type: MyType interface_types: MyType: - {{ parameter_section }}: {{ caller()|indent(8) }} + {{ parameter_section }}: {{ caller()|indent(6) }} {%- endmacro %} {% macro parameters() %} interfaces: @@ -105,7 +105,7 @@ OPERATION_MACROS = """ interface_types: MyType: my_operation: - {{ parameter_section }}: {{ caller()|indent(10) }} + {{ parameter_section }}: {{ caller()|indent(8) }} {%- endmacro %} {% macro parameters() %} interfaces: @@ -478,8 +478,7 @@ topology_template: # Parameter [email protected](reason='fix for capabilities') [email protected]('macros,name,parameter_section', PERMUTATIONS) [email protected]('macros,name,parameter_section', (('capability', 'node', 'attributes'),)) def test_template_parameter_missing(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -537,7 +536,6 @@ my_parameter: values=values), import_profile=True).assert_success() [email protected](reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( PERMUTATIONS, data.ENTRY_SCHEMA_VALUES_BAD, @@ -602,7 +600,6 @@ my_parameter: parameter_section=parameter_section), import_profile=True).assert_success() [email protected](reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_map_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ @@ -667,7 +664,6 @@ my_parameter: values=values), import_profile=True).assert_success() [email protected](reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( PERMUTATIONS, data.ENTRY_SCHEMA_VALUES_BAD, @@ -732,7 +728,6 @@ my_parameter: parameter_section=parameter_section), import_profile=True).assert_success() [email protected](reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_list_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters_properties.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters_properties.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters_properties.py index 55b44c5..3552a17 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters_properties.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters_properties.py @@ -36,7 +36,6 @@ PERMUTATIONS = tuple( # Required [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name,parameter_section,type_name', matrix( PERMUTATIONS, data.PARAMETER_TYPE_NAMES, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py index fa52232..fdf6f16 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_requirements.py @@ -182,8 +182,8 @@ topology_template: type: MyType requirements: - my_requirement: - capability: MyType2 # can change to anything -""").assert_success() + capability: MyType2 +""").assert_failure() def test_node_template_requirement_capability_type_short_form(parser): @@ -258,13 +258,11 @@ topology_template: """).assert_success() [email protected](reason='fix') def test_node_template_requirement_capability_name_not_derived(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: - MyType1: - derived_from: MyType2 + MyType1: {} MyType2: {} node_types: MyType1: @@ -387,7 +385,6 @@ topology_template: """).assert_success() [email protected](reason='fix') def test_node_template_requirement_node_type_not_derived(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -501,14 +498,12 @@ topology_template: """).assert_success() [email protected](reason='fix') def test_node_template_requirement_node_template_not_derived(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: MyType1: {} - MyType2: - derived_from: MyType1 + MyType2: {} node_types: MyType1: requirements: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/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 9636b7b..07a0d9b 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 @@ -130,7 +130,7 @@ topology_template: # Repository [email protected](reason='not yet supported') [email protected](reason='not yet implemented') def test_import_repository(parser, repository): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -149,7 +149,7 @@ topology_template: # Namespace [email protected](reason='not yet supported') [email protected](reason='not yet implemented') def test_import_namespace(parser, repository): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/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 index 3c7dc20..6343442 100644 --- 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 @@ -59,6 +59,12 @@ PERMUTATIONS = ( ('relationship', 'node') ) +PERMUTATIONS_NO_RELATIONSHIP = tuple( + (macros, name) + for macros, name in PERMUTATIONS + if macros != 'relationship' +) + # Interfaces section @@ -152,27 +158,26 @@ MyInterface: """, dict(name=name)).assert_success() [email protected](reason='fix for node.relationship') [email protected]('macros,name', PERMUTATIONS) +# We are skipping relationship interfaces, because node requirements can be overridden completely [email protected]('macros,name', PERMUTATIONS_NO_RELATIONSHIP) def test_type_interface_type_override_bad(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 {{- additions() }} interface_types: MyType1: {} - MyType2: - derived_from: MyType1 + MyType2: {} {{ name }}_types: MyType1: {%- call interfaces() %} MyInterface: - type: MyType2 + type: MyType1 {% endcall %} MyType2: derived_from: MyType1 {%- call interfaces() %} MyInterface: - type: MyType1 + type: MyType2 {% endcall %} """, dict(name=name)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/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 index ff24c81..3cbf47c 100644 --- 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 @@ -131,7 +131,7 @@ interface_types: interfaces: my_interface: type: MyType - {{ parameter_section }}: {{ caller()|indent(20) }} + {{ parameter_section }}: {{ caller()|indent(18) }} {%- endmacro %} """ @@ -162,7 +162,7 @@ interface_types: my_interface: type: MyType my_operation: - {{ parameter_section }}: {{ caller()|indent(22) }} + {{ parameter_section }}: {{ caller()|indent(20) }} {%- endmacro %} """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py index e8a72f4..b7cdaf7 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_type_parameters_inheritance.py @@ -34,6 +34,12 @@ PERMUTATIONS = tuple( if name is not None ) +PERMUTATIONS_NO_RELATIONSHIP = tuple( + (macros, name, parameter_section) + for macros, name, parameter_section in PERMUTATIONS + if macros not in ('relationship-interface', 'relationship-operation') +) + @pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS) def test_type_parameter_add(parser, macros, name, parameter_section): @@ -68,7 +74,6 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section)).assert_success() [email protected](reason='fix for node.capability and node.relationship') @pytest.mark.parametrize('macros,name,parameter_section', PERMUTATIONS) def test_type_parameter_type_override(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ @@ -92,25 +97,24 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section)).assert_success() [email protected](reason='fix for node.capability and node.relationship') [email protected]('macros,name,parameter_section', PERMUTATIONS) +# We are skipping relationship interfaces, because node requirements can be overridden completely [email protected]('macros,name,parameter_section', PERMUTATIONS_NO_RELATIONSHIP) def test_type_parameter_type_override_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 {{- additions() }} data_types: MyDataType1: {} - MyDataType2: - derived_from: MyDataType1 + MyDataType2: {} {%- if name != 'data' %} {{ name }}_types: {%- endif %} {%- call parameters('MyType1') %} my_parameter: - type: MyDataType2 + type: MyDataType1 {% endcall %} {%- call parameters('MyType2', 'MyType1') %} my_parameter: - type: MyDataType1 + type: MyDataType2 {% endcall %} """, dict(name=name, parameter_section=parameter_section)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py index c3491d1..5904a89 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_capabilities.py @@ -158,18 +158,17 @@ def test_node_type_capability_type_override_bad(parser): tosca_definitions_version: tosca_simple_yaml_1_0 capability_types: MyType1: {} - MyType2: - derived_from: MyType1 + MyType2: {} node_types: MyType1: capabilities: my_capability: - type: MyType2 + type: MyType1 MyType2: derived_from: MyType1 capabilities: my_capability: - type: MyType1 + type: MyType2 """).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py index ee34a3a..257fab1 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_type/test_node_type_relationship_interfaces.py @@ -18,8 +18,6 @@ These tests are in addition to those in common/test_type_interface.py. """ -import pytest - # Type @@ -32,8 +30,7 @@ relationship_types: MyType: {} interface_types: MyType1: {} - MyType2: - derived_from: MyType1 + MyType2: {} node_types: MyType1: requirements: @@ -53,40 +50,5 @@ node_types: type: MyType interfaces: my_interface: - type: MyType2 + type: MyType2 # overriding the requirement has no restrictions """).assert_success() - - [email protected](reason='fix') -def test_node_type_relationship_interface_type_override_bad(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -capability_types: - MyType: {} -relationship_types: - MyType: {} -interface_types: - MyType1: {} - MyType2: - derived_from: 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() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ec66be48/tests/requirements.txt ---------------------------------------------------------------------- diff --git a/tests/requirements.txt b/tests/requirements.txt index fbc7124..a958737 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -10,13 +10,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -testtools==2.3.0 fasteners==0.14.1 sh==1.12.14 -tornado==4.3 # last release to support Python 2.6 mock==2.0.0 pylint==1.6.5 # see ARIA-314 about upgrading to 1.7 -pytest==3.2.2 +pytest==3.2.3 pytest-cov==2.5.1 -pytest-mock==1.6.2 -pytest-xdist==1.20.0 +pytest-mock==1.6.3 +pytest-xdist==1.20.1 +testtools==2.3.0 +tornado==4.3 # last release to support Python 2.6
