Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-1-parser-test-suite f2e8cf883 -> 5792ac747
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/5792ac74 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5792ac74 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5792ac74 Branch: refs/heads/ARIA-1-parser-test-suite Commit: 5792ac7478014ef1dcf7d29a86a868f046224626 Parents: f2e8cf8 Author: Tal Liron <[email protected]> Authored: Tue Oct 31 13:42:44 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Tue Oct 31 13:42:44 2017 -0500 ---------------------------------------------------------------------- .../simple_v1_0/modeling/interfaces.py | 25 +++++++++++--------- .../simple_v1_0/modeling/parameters.py | 2 +- .../templates/common/test_template_interface.py | 7 ------ .../test_template_parameters_properties.py | 20 +++++++--------- 4 files changed, 24 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5792ac74/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 7580ef3..af536c3 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py @@ -460,14 +460,21 @@ def merge_interface_definitions_from_their_types(context, interfaces, presentati merge_interface_definition(context, interface, the_type, presentation, 'type') -def assign_raw_inputs(context, values, assignments, definitions, interface_name, operation_name, +def assign_raw_inputs(context, raw, assignments, definitions, interface_name, operation_name, presentation): - if not assignments: - return + if assignments is None: + assignments = {} # Make sure we have the dict - if ('inputs' not in values) or (values['inputs'] is None): - values['inputs'] = OrderedDict() + if ('inputs' not in raw) or (raw['inputs'] is None): + raw['inputs'] = OrderedDict() + + # Defaults + if definitions: + for input_name, definition in definitions.iteritems(): + if ('default' in definition._raw) and (input_name not in raw['inputs']): + raw['inputs'][input_name] = coerce_parameter_value(context, definition, definition, + definition.default, 'default') # Assign inputs for input_name, assignment in assignments.iteritems(): @@ -485,12 +492,8 @@ def assign_raw_inputs(context, values, assignments, definitions, interface_name, locator=assignment._locator, level=Issue.BETWEEN_TYPES) definition = definitions.get(input_name) if definitions is not None else None - - # Note: default value has already been assigned - - # Coerce value - values['inputs'][input_name] = coerce_parameter_value(context, assignment, definition, - assignment.value) + raw['inputs'][input_name] = coerce_parameter_value(context, assignment, definition, + assignment.value) def validate_required_inputs(context, presentation, assignment, definition, original_assignment, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5792ac74/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 c3a1800..60d760a 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py @@ -99,7 +99,7 @@ def get_assigned_and_defined_parameter_values(context, presentation, field_name) if (name not in values) and \ (('default' in definition._raw) or (field_name == 'attribute')): values[name] = coerce_parameter_value(context, presentation, definition, - definition.default) + definition.default, 'default') validate_required_values(context, presentation, values, definitions) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5792ac74/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py index 327a12e..781d53b 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py @@ -276,7 +276,6 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( PERMUTATIONS, data.PARAMETER_VALUES, @@ -315,7 +314,6 @@ MyInterface: value=value)).assert_success() [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( PERMUTATIONS, data.PARAMETER_VALUES, @@ -486,7 +484,6 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name', PERMUTATIONS) def test_template_interface_operation_from_interface_type(parser, macros, name): parser.parse_literal(MACROS[macros] + """ @@ -775,7 +772,6 @@ MyInterface: # Operation input [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( PERMUTATIONS, data.PARAMETER_VALUES, @@ -816,7 +812,6 @@ MyInterface: value=value)).assert_success() [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( PERMUTATIONS, data.PARAMETER_VALUES, @@ -858,7 +853,6 @@ MyInterface: value=value)).assert_success() [email protected](reason='fix') @pytest.mark.parametrize('macros,name', PERMUTATIONS) def test_template_interface_operation_input_missing(parser, macros, name): parser.parse_literal(MACROS[macros] + """ @@ -888,7 +882,6 @@ MyInterface: # Unicode [email protected](reason='fix for relationships') @pytest.mark.parametrize('macros,name', PERMUTATIONS) def test_template_interface_unicode(parser, macros, name): parser.parse_literal(MACROS[macros] + """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5792ac74/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 b0f40f0..bd82766 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 @@ -15,7 +15,7 @@ # limitations under the License. """ -Unified testing for properties. +Unified testing for properties (including inputs). These tests are in addition to the common tests for parameters in test_template_parameters.py. """ @@ -53,7 +53,7 @@ data_types: {{ name }}_types: MyType: {%- call type_parameters() %} -my_property: +my_parameter: type: {{ type_name }} {% endcall %} topology_template: @@ -84,7 +84,7 @@ data_types: {{ name }}_types: MyType: {%- call type_parameters() %} -my_property: +my_parameter: type: {{ type_name }} required: false {% endcall %} @@ -99,13 +99,11 @@ topology_template: type_name=type_name)).assert_success() -#@pytest.mark.skip(reason='fix for relationship inputs') [email protected]('macros,name,parameter_section,type_name,value', (('relationship-local-interface', 'node', 'inputs', 'string', 'val'),)) -# @pytest.mark.parametrize('macros,name,parameter_section,type_name,value', matrix( -# PERMUTATIONS, -# data.PARAMETER_VALUES, -# counts=(3, 2) -# )) [email protected]('macros,name,parameter_section,type_name,value', matrix( + PERMUTATIONS, + data.PARAMETER_VALUES, + counts=(3, 2) +)) def test_template_parameter_required_with_default(parser, macros, name, parameter_section, type_name, value): parser.parse_literal(MACROS[macros] + """ @@ -119,7 +117,7 @@ data_types: {{ name }}_types: MyType: {%- call type_parameters() %} -my_property: +my_parameter: type: {{ type_name }} default: {{ value }} {% endcall %}
