Substitution mapping and copy tests * Fix subtitution mapping requirement validation
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/12e86086 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/12e86086 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/12e86086 Branch: refs/heads/ARIA-1-parser-test-suite Commit: 12e8608634c301431c9bec15e54e351205f5c70d Parents: 740818a Author: Tal Liron <[email protected]> Authored: Tue Oct 3 16:23:23 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Tue Oct 3 16:23:23 2017 -0500 ---------------------------------------------------------------------- .../simple_v1_0/modeling/copy.py | 2 +- .../modeling/substitution_mappings.py | 23 +- .../aria_extension_tosca/simple_v1_0/data.py | 2 + .../simple_v1_0/templates/common/test_copy.py | 26 +- .../templates/common/test_template_interface.py | 56 +-- .../common/test_template_parameters.py | 26 +- .../common/test_template_properties.py | 10 +- .../templates/common/test_templates.py | 41 +- .../test_node_template_artifacts.py | 41 +- ...est_node_template_node_filter_constraints.py | 346 +++++++++++++++ .../test_node_template_node_filters.py | 26 +- ...st_node_template_node_filters_constraints.py | 322 -------------- .../templates/test_inputs_and_ouputs.py | 2 + .../templates/test_substitution_mappings.py | 424 ++++++++++++++++++- .../templates/test_topology_template.py | 19 + .../types/common/test_type_interfaces.py | 42 +- .../types/common/test_type_parameters.py | 34 +- .../types/common/test_type_properties.py | 39 +- .../simple_v1_0/types/common/test_types.py | 26 +- 19 files changed, 1004 insertions(+), 503 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/extensions/aria_extension_tosca/simple_v1_0/modeling/copy.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/copy.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/copy.py index bd9037f..b3c2e49 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/copy.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/copy.py @@ -23,7 +23,7 @@ def get_default_raw_from_copy(presentation, field_name): """ copy = presentation._raw.get('copy') - if copy is not None: + if isinstance(copy, basestring): templates = getattr(presentation._container, field_name) if templates is not None: template = templates.get(copy) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py index 2bbc437..ae2f924 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/substitution_mappings.py @@ -18,8 +18,7 @@ from aria.parser.validation import Issue def validate_substitution_mappings_requirement(context, presentation): - - # validate that the requirement in substitution_mapping is defined in the substitution node type + # Validate that the requirement in substitution_mapping is defined in the substitution node type substitution_node_type = presentation._container._get_type(context) if substitution_node_type is None: return @@ -38,7 +37,7 @@ def validate_substitution_mappings_requirement(context, presentation): _report_invalid_mapping_format(context, presentation, field='requirement') return - # validate that the mapped requirement is defined in the corresponding node template + # Validate that the mapped requirement is defined in the corresponding node template node_template = _get_node_template(context, presentation) if node_template is None: _report_missing_node_template(context, presentation, field='requirement') @@ -57,14 +56,14 @@ def validate_substitution_mappings_requirement(context, presentation): locator=presentation._locator, level=Issue.BETWEEN_TYPES) return - # validate that the requirement's capability type in substitution_mapping is derived from the + # Validate that the requirement's capability type in substitution_mapping is derived from the # requirement's capability type in the corresponding node template substitution_type_requirement_capability_type = \ substitution_type_requirement._get_capability_type(context) node_template_requirement_capability_type = \ node_template_requirement._get_capability(context)[0] - if not node_template_requirement_capability_type._is_descendant( - context, substitution_type_requirement_capability_type): + if not substitution_type_requirement_capability_type._is_descendant( + context, node_template_requirement_capability_type): context.validation.report( u'substitution mapping requirement "{0}" of capability type "{1}" is not a descendant ' u'of the mapped node template capability type "{2}"'.format( @@ -75,8 +74,7 @@ def validate_substitution_mappings_requirement(context, presentation): def validate_substitution_mappings_capability(context, presentation): - - # validate that the capability in substitution_mapping is defined in the substitution node type + # Validate that the capability in substitution_mapping is defined in the substitution node type substitution_node_type = presentation._container._get_type(context) if substitution_node_type is None: return @@ -94,7 +92,7 @@ def validate_substitution_mappings_capability(context, presentation): _report_invalid_mapping_format(context, presentation, field='capability') return - # validate that the capability in substitution_mapping is declared in the corresponding + # Validate that the capability in substitution_mapping is declared in the corresponding # node template node_template = _get_node_template(context, presentation) if node_template is None: @@ -112,11 +110,10 @@ def validate_substitution_mappings_capability(context, presentation): locator=presentation._locator, level=Issue.BETWEEN_TYPES) return - # validate that the capability type in substitution_mapping is derived from the capability type + # Validate that the capability type in substitution_mapping is derived from the capability type # in the corresponding node template substitution_type_capability_type = substitution_type_capability._get_type(context) node_template_capability_type = node_template_capability._get_type(context) - if not substitution_type_capability_type._is_descendant(context, node_template_capability_type): context.validation.report( u'node template capability type "{0}" is not a descendant of substitution mapping ' @@ -132,7 +129,9 @@ def validate_substitution_mappings_capability(context, presentation): # def _validate_mapping_format(presentation): - """Validate that the mapping is a list of 2 strings""" + """ + Validate that the mapping is a list of 2 strings. + """ if not isinstance(presentation._raw, list) or \ len(presentation._raw) != 2 or \ not isinstance(presentation._raw[0], basestring) or \ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/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 9f15538..104e6bb 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py @@ -45,8 +45,10 @@ CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT = ('length', 'min_length', 'max_length') PRIMITIVE_VALUES = ('null', 'true', 'a string', '123', '0.123', '[]', '{}') NOT_A_DICT = ('null', 'true', 'a string', '123', '0.123', '[]') +NOT_A_DICT_WITH_ONE_KEY = NOT_A_DICT + ('{}', '{k1: v1, k2: v2}',) NOT_A_DICT_OR_STRING = ('null', 'true', '123', '0.123', '[]') NOT_A_LIST = ('null', 'true', 'a string', '123', '0.123', '{}') +NOT_A_LIST_OF_TWO = NOT_A_LIST + ('[]', '[a]', '[a, b, c]') NOT_A_STRING = ('null', 'true', '123', '0.123', '[]', '{}') NOT_A_BOOL = ('null', 'a string', '123', '0.123', '[]', '{}') NOT_A_RANGE = NOT_A_LIST + ( http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py index 57eecad..7d333e4 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_copy.py @@ -17,12 +17,28 @@ import pytest from ... import data +from ......mechanisms.utils import matrix -CASES = ('node', 'relationship') +PERMUTATIONS = ('node', 'relationship') [email protected]('name', CASES) [email protected]('name,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) +def test_templates_copy_syntax_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: {} +topology_template: + {{ section }}: + my_template: + type: MyType + copying_template: + copy: {{ value }} +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() + + [email protected]('name', PERMUTATIONS) def test_templates_copy(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -32,12 +48,12 @@ topology_template: {{ section }}: my_template: type: MyType - copy_template: + copying_template: copy: my_template """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() [email protected]('name', CASES) [email protected]('name', PERMUTATIONS) def test_templates_copy_unknown(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -47,6 +63,6 @@ topology_template: {{ section }}: my_template: type: MyType - copy_template: + copying_template: copy: unknown """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/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 2b78dfc..327a12e 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 @@ -110,7 +110,7 @@ MACROS = { 'relationship-template': RELATIONSHIP_TEMPLATE_MACROS } -CASES = ( +PERMUTATIONS = ( ('main', 'node'), ('main', 'group'), ('main', 'relationship'), @@ -123,7 +123,7 @@ CASES = ( # Interfaces section @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT, counts=(2, 1) )) @@ -148,7 +148,7 @@ topology_template: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interfaces_section_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -173,7 +173,7 @@ topology_template: # Interface @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT, counts=(2, 1) )) @@ -199,7 +199,7 @@ MyInterface: {{ value }} """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -225,7 +225,7 @@ MyInterface: {} # Interface input @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT, counts=(2, 1) )) @@ -252,7 +252,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_inputs_section_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -278,7 +278,7 @@ MyInterface: @pytest.mark.skip(reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -317,7 +317,7 @@ MyInterface: @pytest.mark.skip(reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -354,7 +354,7 @@ MyInterface: value=value)).assert_success() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_input_missing(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -382,7 +382,7 @@ MyInterface: # Operation @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) @@ -410,7 +410,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -436,7 +436,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -461,7 +461,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_from_type(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -487,7 +487,7 @@ MyInterface: @pytest.mark.skip(reason='fix for relationships') [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_from_interface_type(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -512,7 +512,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_missing(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -539,7 +539,7 @@ MyInterface: # Operation implementation @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) @@ -568,7 +568,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_implementation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -595,7 +595,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_implementation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -622,7 +622,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_STRING, counts=(2, 1) )) @@ -653,7 +653,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_implementation_primary_short_form(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -680,7 +680,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_LIST, counts=(2, 1) )) @@ -712,7 +712,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_STRING, counts=(2, 1) )) @@ -745,7 +745,7 @@ MyInterface: """, dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_implementation_dependencies_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ @@ -777,7 +777,7 @@ MyInterface: @pytest.mark.skip(reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -818,7 +818,7 @@ MyInterface: @pytest.mark.skip(reason='fix for relationships') @pytest.mark.parametrize('macros,name,type_name,value', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -859,7 +859,7 @@ MyInterface: @pytest.mark.skip(reason='fix') [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_operation_input_missing(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -889,7 +889,7 @@ MyInterface: # Unicode @pytest.mark.skip(reason='fix for relationships') [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_template_interface_unicode(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/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 aac6f88..545f8dc 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 @@ -396,7 +396,7 @@ MACROS = { 'relationship-local-operation': RELATIONSHIP_LOCAL_OPERATION_MACROS } -CASES = ( +PERMUTATIONS = ( ('main', 'node', 'properties'), ('main', 'node', 'attributes'), ('main', 'group', 'properties'), @@ -431,7 +431,7 @@ CASES = ( # Parameters section @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT, counts=(3, 1) )) @@ -455,7 +455,7 @@ topology_template: parameter_section=parameter_section, value=value)).assert_failure() [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameters_section_syntax_empty(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -479,7 +479,7 @@ topology_template: # Parameter @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_missing(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -503,7 +503,7 @@ my_parameter: a value # Entry schema @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - CASES, + PERMUTATIONS, data.ENTRY_SCHEMA_VALUES, counts=(3, 1) )) @@ -539,7 +539,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - CASES, + PERMUTATIONS, data.ENTRY_SCHEMA_VALUES_BAD, counts=(3, 1) )) @@ -573,7 +573,7 @@ my_parameter: values=values), import_profile=True).assert_failure() [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_map_required_field(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -603,7 +603,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_map_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -633,7 +633,7 @@ my_parameter: @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - CASES, + PERMUTATIONS, data.ENTRY_SCHEMA_VALUES, counts=(3, 1) )) @@ -669,7 +669,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - CASES, + PERMUTATIONS, data.ENTRY_SCHEMA_VALUES_BAD, counts=(3, 1) )) @@ -703,7 +703,7 @@ my_parameter: values=values), import_profile=True).assert_failure() [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_list_required_field(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -733,7 +733,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_list_required_field_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -764,7 +764,7 @@ my_parameter: # Unicode [email protected]('macros,name,parameter_section', CASES) [email protected]('macros,name,parameter_section', PERMUTATIONS) def test_template_parameter_unicode(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py index 35fda49..4c947d2 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_properties.py @@ -22,12 +22,12 @@ These tests are in addition to the common tests for parameters in test_template_ import pytest -from .test_template_parameters import (MACROS, CASES as PARAMETER_CASES) +from .test_template_parameters import (MACROS, PERMUTATIONS as PARAMETER_CASES) from ... import data from ......mechanisms.utils import matrix -CASES = tuple( +PERMUTATIONS = tuple( (macros, name, parameter_section) for macros, name, parameter_section in PARAMETER_CASES if parameter_section != 'attributes' @@ -38,7 +38,7 @@ CASES = tuple( @pytest.mark.skip(reason='fix for relationships') @pytest.mark.parametrize('macros,name,parameter_section,type_name', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_TYPE_NAMES, counts=(3, 1) )) @@ -69,7 +69,7 @@ topology_template: @pytest.mark.parametrize('macros,name,parameter_section,type_name', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_TYPE_NAMES, counts=(3, 1) )) @@ -102,7 +102,7 @@ topology_template: @pytest.mark.skip(reason='fix for relationship inputs') @pytest.mark.parametrize('macros,name,parameter_section,type_name,value', matrix( - CASES, + PERMUTATIONS, data.PARAMETER_VALUES, counts=(3, 2) )) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py index d7a5142..62a10ed 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py @@ -20,13 +20,13 @@ from ... import data from ......mechanisms.utils import matrix -CASES = ('node', 'group', 'relationship', 'policy') +PERMUTATIONS = ('node', 'group', 'relationship', 'policy') # Templates section @pytest.mark.parametrize('name,value', matrix( - CASES, + PERMUTATIONS, data.NOT_A_DICT )) def test_templates_section_syntax_type(parser, name, value): @@ -37,7 +37,7 @@ topology_template: """, dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('name', CASES) [email protected]('name', PERMUTATIONS) def test_templates_section_syntax_empty(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -48,39 +48,49 @@ topology_template: # Template [email protected]('name', CASES) [email protected]('name', PERMUTATIONS) def test_template_syntax_unsupported(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: {} topology_template: {{ section }}: my_template: + type: MyType unsupported: {} +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() + + [email protected]('name', PERMUTATIONS) +def test_template_syntax_empty(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: + {{ section }}: + my_template: {} # "type" is required """, dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() # Description [email protected]('name,value', matrix( - CASES, - data.NOT_A_STRING -)) [email protected]('name,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_template_description_syntax_type(parser, name, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: {} topology_template: {{ section }}: my_template: + type: MyType description: {{ value }} -""", dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() # Type [email protected]('name,value', matrix( - CASES, - data.NOT_A_STRING -)) [email protected]('name,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_template_type_syntax_type(parser, name, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -90,7 +100,8 @@ topology_template: type: {{ value }} """, dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('name', CASES) + [email protected]('name', PERMUTATIONS) def test_template_type_unknown(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -103,7 +114,7 @@ topology_template: # Unicode [email protected]('name', CASES) [email protected]('name', PERMUTATIONS) def test_template_unicode(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py index d7c91a0..e9ccc89 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_artifacts.py @@ -14,6 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Here we are testing not only artifacts attached to node templates, but also artifacts attached to +node types. The reason is that artifacts attached node types use the same property assignment +(rather than definition) syntax we see in templates. +""" import pytest @@ -48,7 +53,7 @@ MACROS = { 'type': TYPE_MACROS } -CASES = ( +PERMUTATIONS = ( 'template', 'type' ) @@ -57,7 +62,7 @@ CASES = ( # Artifacts section [email protected]('macros,value', matrix(CASES, data.NOT_A_DICT)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_DICT)) def test_node_template_artifacts_section_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -67,7 +72,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifacts_section_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -79,7 +84,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Artifact [email protected]('macros,value', matrix(CASES, data.NOT_A_DICT)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_DICT)) def test_node_template_artifact_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -89,7 +94,7 @@ my_artifact: {{ value }} """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_syntax_unsupported(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -101,7 +106,7 @@ my_artifact: """).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -113,7 +118,7 @@ my_artifact: {} # "type" and "file" are required # Type [email protected]('macros,value', matrix(CASES, data.NOT_A_STRING)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_node_template_artifact_type_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -125,7 +130,7 @@ my_artifact: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_type_unknown(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -139,7 +144,7 @@ my_artifact: # File [email protected]('macros,value', matrix(CASES, data.NOT_A_STRING)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_node_template_artifact_file_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -153,7 +158,7 @@ my_artifact: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_file(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -169,7 +174,7 @@ my_artifact: # Description [email protected]('macros,value', matrix(CASES, data.NOT_A_STRING)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_node_template_artifact_description_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -184,7 +189,7 @@ my_artifact: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_description(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -201,7 +206,7 @@ my_artifact: # Repository [email protected]('macros,value', matrix(CASES, data.NOT_A_STRING)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_node_template_artifact_repository_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -216,7 +221,7 @@ my_artifact: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_repository_unknown(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -231,7 +236,7 @@ my_artifact: """).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_repository(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -251,7 +256,7 @@ my_artifact: # Deploy path [email protected]('macros,value', matrix(CASES, data.NOT_A_STRING)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_STRING)) def test_node_template_artifact_deploy_path_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -266,7 +271,7 @@ my_artifact: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_deploy_path(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -283,7 +288,7 @@ my_artifact: # Unicode [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_artifact_unicode(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py new file mode 100644 index 0000000..fad439e --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filter_constraints.py @@ -0,0 +1,346 @@ +# -*- 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. + +""" +Compare with test_type_properties.py. Note that though the constraints are the same, their syntax +is very different, making it difficult to test all permutations together. +""" + + +import pytest + +from ... import data +from ......mechanisms.utils import matrix + + +# Properties for node filter in node template +MAIN_MACROS = """ +{% macro additions() %} +data_types: + MyType: + properties: + my_field: + type: string +node_types: + MyType1: {} + MyType2: + properties: + data_property: + type: MyType + string_property: + type: string +{%- endmacro %} +{% macro properties() %} + node_filter: + properties: {{ caller()|indent(10) }} +{%- endmacro %} +""" + +# Capability properties for node filter in node template +MAIN_CAPABILITY_MACROS = """ +{% macro additions() %} +data_types: + MyType: + properties: + my_field: + type: string +capability_types: + MyType: + properties: + data_property: + type: MyType + string_property: + type: string +node_types: + MyType1: {} + MyType2: + capabilities: + my_capability: MyType +{%- endmacro %} +{% macro properties() %} + node_filter: + capabilities: + - my_capability: + properties: {{ caller()|indent(16) }} +{%- endmacro %} +""" + +# Properties for node filter in requirement +REQUIREMENT_MACROS = """ +{% macro additions() %} +data_types: + MyType: + properties: + my_field: + type: string +capability_types: + MyType: {} +node_types: + MyType1: + requirements: + - my_requirement: + capability: MyType + MyType2: + properties: + data_property: + type: MyType + string_property: + type: string + capabilities: + my_capability: MyType +{%- endmacro %} +{% macro properties() %} + requirements: + - my_requirement: + node: MyType2 + node_filter: + properties: {{ caller()|indent(16) }} +{%- endmacro %} +""" + +# Capability properties for node filter in requirement +REQUIREMENT_CAPABILITY_MACROS = """ +{% macro additions() %} +data_types: + MyType: + properties: + my_field: + type: string +capability_types: + MyType: + properties: + data_property: + type: MyType + string_property: + type: string +node_types: + MyType1: + requirements: + - my_requirement: + capability: MyType + MyType2: + capabilities: + my_capability: MyType +{%- endmacro %} +{% macro properties() %} + requirements: + - my_requirement: + node: MyType2 + node_filter: + capabilities: + - my_capability: + properties: {{ caller()|indent(22) }} +{%- endmacro %} +""" + +MACROS = { + 'main': MAIN_MACROS, + 'requirement': REQUIREMENT_MACROS, + 'main-capability': MAIN_CAPABILITY_MACROS, + 'requirement-capability': REQUIREMENT_CAPABILITY_MACROS +} + +PERMUTATIONS = ( + 'main', 'requirement', 'main-capability', 'requirement-capability' +) + + + [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_DICT_WITH_ONE_KEY)) +def test_node_template_node_filter_constraints_syntax_type(parser, macros, value): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: {{ value }} +{% endcall %} +""", dict(value=value)).assert_failure() + + [email protected]('macros', PERMUTATIONS) +def test_node_template_node_filter_constraints_syntax_empty(parser, macros): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: {} +{% endcall %} +""").assert_failure() + + [email protected]('macros', PERMUTATIONS) +def test_node_template_node_filter_constraints_syntax_unsupported(parser, macros): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { unsupported: a string } +{% endcall %} +""").assert_failure() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, data.CONSTRAINTS_WITH_VALUE)) +def test_node_template_node_filter_constraints_with_value(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { {{ constraint }}: {my_field: a string} } +{% endcall %} +""", dict(constraint=constraint)).assert_success() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_LIST)) +def test_node_template_node_filter_constraints_with_value_list(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, {my_field: c} ] } +{% endcall %} +""", dict(constraint=constraint)).assert_success() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_RANGE)) +def test_node_template_node_filter_constraints_with_value_range(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { {{ constraint }}: [ {my_field: string a}, {my_field: string b} ] } +{% endcall %} +""", dict(constraint=constraint)).assert_success() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_RANGE)) +def test_node_template_node_filter_constraints_with_value_range_too_many(parser, macros, + constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, {my_field: c} ] } +{% endcall %} +""", dict(constraint=constraint)).assert_failure() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_RANGE)) +def test_node_template_node_filter_constraints_with_value_range_bad(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- data_property: { {{ constraint }}: [ {my_field: string b}, {my_field: string a} ] } +{% endcall %} +""", dict(constraint=constraint)).assert_failure() + + [email protected]('macros', PERMUTATIONS) +def test_node_template_node_filter_constraints_pattern(parser, macros): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- string_property: { pattern: ^pattern$ } +{% endcall %} +""").assert_success() + + [email protected]('macros', PERMUTATIONS) +def test_node_template_node_filter_constraints_pattern_bad(parser, macros): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- string_property: { pattern: ( } +{% endcall %} +""").assert_failure() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT)) +def test_node_template_node_filter_constraints_with_value_integer(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- string_property: { {{ constraint }}: 1 } +{% endcall %} +""", dict(constraint=constraint)).assert_success() + + [email protected]('macros,constraint', matrix(PERMUTATIONS, + data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT)) +def test_node_template_node_filter_constraints_with_value_integer_bad(parser, macros, constraint): + parser.parse_literal(MACROS[macros] + """ +tosca_definitions_version: tosca_simple_yaml_1_0 +{{- additions() }} +topology_template: + node_templates: + my_node: + type: MyType1 +{%- call properties() %} +- string_property: { {{ constraint }}: -1 } +{% endcall %} +""", dict(constraint=constraint)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py index bed3a62..0a54961 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters.py @@ -70,12 +70,12 @@ MACROS = { 'requirement': REQUIREMENT_MACROS } -CASES = ( +PERMUTATIONS = ( 'main', 'requirement' ) [email protected]('macros,value', matrix(CASES, data.NOT_A_DICT)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_DICT)) def test_node_template_node_filter_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -90,7 +90,7 @@ topology_template: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_syntax_unsupported(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -105,7 +105,7 @@ unsupported: {} """).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -122,7 +122,7 @@ topology_template: # Properties section [email protected]('macros,value', matrix(CASES, data.NOT_A_LIST)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_LIST)) def test_node_template_node_filter_properties_section_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -137,7 +137,7 @@ properties: {{ value }} """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_properties_section_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -154,7 +154,7 @@ properties: [] # Capabilities section [email protected]('macros,value', matrix(CASES, data.NOT_A_LIST)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_LIST)) def test_node_template_node_filter_capabilities_section_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -169,7 +169,7 @@ capabilities: {{ value }} """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_capabilities_section_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -186,7 +186,7 @@ capabilities: [] # Capability [email protected]('macros,value', matrix(CASES, data.NOT_A_DICT)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_DICT)) def test_node_template_node_filter_capability_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -202,7 +202,7 @@ capabilities: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_capability_syntax_unsupported(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -219,7 +219,7 @@ capabilities: """).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_capability_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -237,7 +237,7 @@ capabilities: # Capability properties section [email protected]('macros,value', matrix(CASES, data.NOT_A_LIST)) [email protected]('macros,value', matrix(PERMUTATIONS, data.NOT_A_LIST)) def test_node_template_node_filter_capability_properties_section_syntax_type(parser, macros, value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -254,7 +254,7 @@ capabilities: """, dict(value=value)).assert_failure() [email protected]('macros', CASES) [email protected]('macros', PERMUTATIONS) def test_node_template_node_filter_capability_properties_section_syntax_empty(parser, macros): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py deleted file mode 100644 index cb55803..0000000 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_node_filters_constraints.py +++ /dev/null @@ -1,322 +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 pytest - -from ... import data -from ......mechanisms.utils import matrix - - -# Properties for node filter in node template -MAIN_MACROS = """ -{% macro additions() %} -data_types: - MyType: - properties: - my_field: - type: string -node_types: - MyType1: {} - MyType2: - properties: - data_property: - type: MyType - string_property: - type: string -{%- endmacro %} -{% macro properties() %} - node_filter: - properties: {{ caller()|indent(10) }} -{%- endmacro %} -""" - -# Capability properties for node filter in node template -MAIN_CAPABILITY_MACROS = """ -{% macro additions() %} -data_types: - MyType: - properties: - my_field: - type: string -capability_types: - MyType: - properties: - data_property: - type: MyType - string_property: - type: string -node_types: - MyType1: {} - MyType2: - capabilities: - my_capability: MyType -{%- endmacro %} -{% macro properties() %} - node_filter: - capabilities: - - my_capability: - properties: {{ caller()|indent(16) }} -{%- endmacro %} -""" - -# Properties for node filter in requirement -REQUIREMENT_MACROS = """ -{% macro additions() %} -data_types: - MyType: - properties: - my_field: - type: string -capability_types: - MyType: {} -node_types: - MyType1: - requirements: - - my_requirement: - capability: MyType - MyType2: - properties: - data_property: - type: MyType - string_property: - type: string - capabilities: - my_capability: MyType -{%- endmacro %} -{% macro properties() %} - requirements: - - my_requirement: - node: MyType2 - node_filter: - properties: {{ caller()|indent(16) }} -{%- endmacro %} -""" - -# Capability properties for node filter in requirement -REQUIREMENT_CAPABILITY_MACROS = """ -{% macro additions() %} -data_types: - MyType: - properties: - my_field: - type: string -capability_types: - MyType: - properties: - data_property: - type: MyType - string_property: - type: string -node_types: - MyType1: - requirements: - - my_requirement: - capability: MyType - MyType2: - capabilities: - my_capability: MyType -{%- endmacro %} -{% macro properties() %} - requirements: - - my_requirement: - node: MyType2 - node_filter: - capabilities: - - my_capability: - properties: {{ caller()|indent(22) }} -{%- endmacro %} -""" - -MACROS = { - 'main': MAIN_MACROS, - 'requirement': REQUIREMENT_MACROS, - 'main-capability': MAIN_CAPABILITY_MACROS, - 'requirement-capability': REQUIREMENT_CAPABILITY_MACROS -} - -CASES = ( - 'main', 'requirement', 'main-capability', 'requirement-capability' -) - - - [email protected]('macros', CASES) -def test_node_template_node_filter_constraints_syntax_empty(parser, macros): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: {} -{% endcall %} -""").assert_failure() - - [email protected]('macros', CASES) -def test_node_template_node_filter_constraints_syntax_unsupported(parser, macros): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { unsupported: a string } -{% endcall %} -""").assert_failure() - - [email protected]('macros,constraint', matrix(CASES, data.CONSTRAINTS_WITH_VALUE)) -def test_node_template_node_filter_constraints_with_value(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { {{ constraint }}: {my_field: a string} } -{% endcall %} -""", dict(constraint=constraint)).assert_success() - - [email protected]('macros,constraint', matrix(CASES, data.CONSTRAINTS_WITH_VALUE_LIST)) -def test_node_template_node_filter_constraints_with_value_list(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, {my_field: c} ] } -{% endcall %} -""", dict(constraint=constraint)).assert_success() - - [email protected]('macros,constraint', matrix(CASES, data.CONSTRAINTS_WITH_VALUE_RANGE)) -def test_node_template_node_filter_constraints_with_value_range(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { {{ constraint }}: [ {my_field: string a}, {my_field: string b} ] } -{% endcall %} -""", dict(constraint=constraint)).assert_success() - - [email protected]('macros,constraint', matrix(CASES, data.CONSTRAINTS_WITH_VALUE_RANGE)) -def test_node_template_node_filter_constraints_with_value_range_too_many(parser, macros, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { {{ constraint }}: [ {my_field: a}, {my_field: b}, {my_field: c} ] } -{% endcall %} -""", dict(constraint=constraint)).assert_failure() - - [email protected]('macros,constraint', matrix(CASES, data.CONSTRAINTS_WITH_VALUE_RANGE)) -def test_node_template_node_filter_constraints_with_value_range_bad(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- data_property: { {{ constraint }}: [ {my_field: string b}, {my_field: string a} ] } -{% endcall %} -""", dict(constraint=constraint)).assert_failure() - - [email protected]('macros', CASES) -def test_node_template_node_filter_constraints_pattern(parser, macros): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- string_property: { pattern: ^pattern$ } -{% endcall %} -""").assert_success() - - [email protected]('macros', CASES) -def test_node_template_node_filter_constraints_pattern_bad(parser, macros): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- string_property: { pattern: ( } -{% endcall %} -""").assert_failure() - - [email protected]('macros,constraint', matrix(CASES, - data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT)) -def test_node_template_node_filter_constraints_with_value_integer(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- string_property: { {{ constraint }}: 1 } -{% endcall %} -""", dict(constraint=constraint)).assert_success() - - [email protected]('macros,constraint', matrix(CASES, - data.CONSTRAINTS_WITH_VALUE_NON_NEGATIVE_INT)) -def test_node_template_node_filter_constraints_with_value_integer_bad(parser, macros, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -topology_template: - node_templates: - my_node: - type: MyType1 -{%- call properties() %} -- string_property: { {{ constraint }}: -1 } -{% endcall %} -""", dict(constraint=constraint)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_inputs_and_ouputs.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_inputs_and_ouputs.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_inputs_and_ouputs.py new file mode 100644 index 0000000..b714df1 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_inputs_and_ouputs.py @@ -0,0 +1,2 @@ + +# TODO http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_substitution_mappings.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_substitution_mappings.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_substitution_mappings.py index a6ce41d..8903b97 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_substitution_mappings.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_substitution_mappings.py @@ -14,16 +14,436 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest -# TODO +from .. import data -def test_topology_template_fields(parser): + [email protected]('value', data.NOT_A_DICT) +def test_substitution_mappings_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: + substitution_mappings: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_substitution_mappings_syntax_unsupported(parser): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 node_types: MyType: {} topology_template: + substitution_mappings: + node_type: MyType + unsupported: {} +""").assert_failure() + + +def test_substitution_mappings_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: + substitution_mappings: {} # "node_type" is required +""").assert_failure() + + +# Node type + +def test_substitution_mappings_node_type_syntax_type(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: description: a description substitution_mappings: + node_type: {{ value }} +""").assert_failure() + + +# Requirements section + [email protected]('value', data.NOT_A_DICT) +def test_substitution_mappings_requirements_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + substitution_mappings: node_type: MyType + requirements: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_substitution_mappings_requirements_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + substitution_mappings: + node_type: MyType + requirements: {} """).assert_success() + + +# Requirement + [email protected]('value', data.NOT_A_LIST_OF_TWO) +def test_substitution_mappings_requirement_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType +topology_template: + substitution_mappings: + node_type: MyType + requirements: + my_requirement: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_substitution_mappings_requirement_same(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + my_requirement: [ my_template, my_internal_requirement ] +""").assert_success() + + +def test_substitution_mappings_requirement_derived(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: + derived_from: MyType1 +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType1 + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType2 +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + my_requirement: [ my_template, my_internal_requirement ] +""").assert_success() + + +def test_substitution_mappings_requirement_bad(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType1 + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType2 +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + my_requirement: [ my_template, my_internal_requirement ] +""").assert_failure() + + +def test_substitution_mappings_requirement_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + unknown: [ my_template, my_internal_requirement ] +""").assert_failure() + + +def test_substitution_mappings_requirement_unknown_mapped_template(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + my_requirement: [ unknown, my_internal_requirement ] +""").assert_failure() + + +def test_substitution_mappings_requirement_unknown_mapped_requirement(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + requirements: + - my_requirement: + capability: MyType + MyInternalType: + requirements: + - my_internal_requirement: + capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + requirements: + my_requirement: [ my_template, unknown ] +""").assert_failure() + + +# Capabilities section + [email protected]('value', data.NOT_A_DICT) +def test_substitution_mappings_capabilities_section_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + substitution_mappings: + node_type: MyType + capabilities: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_substitution_mappings_capabilities_section_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + substitution_mappings: + node_type: MyType + capabilities: {} +""").assert_success() + + +# Capability + [email protected]('value', data.NOT_A_LIST_OF_TWO) +def test_substitution_mappings_capability_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: MyType +topology_template: + substitution_mappings: + node_type: MyType + capabilities: + my_capability: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_substitution_mappings_capability_same(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: MyType + MyInternalType: + capabilities: + my_internal_capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + my_capability: [ my_template, my_internal_capability ] +""").assert_success() + + +def test_substitution_mappings_capability_derived(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: + derived_from: MyType1 +node_types: + MyType: + capabilities: + my_capability: MyType1 + MyInternalType: + capabilities: + my_internal_capability: MyType2 +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + my_capability: [ my_template, my_internal_capability ] +""").assert_success() + + +def test_substitution_mappings_capability_bad(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: {} +node_types: + MyType: + capabilities: + my_capability: MyType1 + MyInternalType: + capabilities: + my_internal_capability: MyType2 +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + my_capability: [ my_template, my_internal_capability ] +""").assert_failure() + + +def test_substitution_mappings_capability_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: MyType + MyInternalType: + capabilities: + my_internal_capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + unknown: [ my_template, my_internal_capability ] +""").assert_failure() + + +def test_substitution_mappings_capability_unknown_mapped_template(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: MyType + MyInternalType: + capabilities: + my_internal_capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + my_capability: [ unknown, my_internal_capability ] +""").assert_failure() + + +def test_substitution_mappings_capability_unknown_mapped_capability(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType: {} +node_types: + MyType: + capabilities: + my_capability: MyType + MyInternalType: + capabilities: + my_internal_capability: MyType +topology_template: + node_templates: + my_template: + type: MyInternalType + substitution_mappings: + node_type: MyType + capabilities: + my_capability: [ my_template, unknown ] +""").assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py index 8e848ee..ac86a4a 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py @@ -40,3 +40,22 @@ def test_topology_template_syntax_empty(parser): tosca_definitions_version: tosca_simple_yaml_1_0 topology_template: {} """).assert_success() + + +# Description + [email protected]('value', data.NOT_A_STRING) +def test_topology_template_description_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: + description: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_topology_template_description(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: + description: a description +""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/12e86086/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 463dd9a..e738d0b 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 @@ -52,7 +52,7 @@ MACROS = { 'relationship': RELATIONSHIP_MACROS } -CASES = ( +PERMUTATIONS = ( ('main', 'node'), ('main', 'group'), ('main', 'relationship'), @@ -63,7 +63,7 @@ CASES = ( # Interfaces section @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_DICT, + PERMUTATIONS, data.NOT_A_DICT, counts=(2, 1) )) def test_type_interfaces_section_syntax_type(parser, macros, name, value): @@ -80,7 +80,7 @@ interface_types: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interfaces_section_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -96,7 +96,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Interface @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_DICT, + PERMUTATIONS, data.NOT_A_DICT, counts=(2, 1) )) def test_type_interface_syntax_type(parser, macros, name, value): @@ -113,7 +113,7 @@ MyInterface: {{ value }} """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -128,7 +128,7 @@ MyInterface: {} # "type" is required # Type [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_type_override(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -153,7 +153,7 @@ MyInterface: @pytest.mark.skip(reason='fix for node.relationship') [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_type_override_bad(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -180,7 +180,7 @@ MyInterface: # Operation @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_DICT_OR_STRING, + PERMUTATIONS, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) def test_type_interface_operation_syntax_type(parser, macros, name, value): @@ -199,7 +199,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -217,7 +217,7 @@ MyInterface: """, dict(name=name)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -237,7 +237,7 @@ MyInterface: # Operation description @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_STRING, + PERMUTATIONS, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_description_syntax_type(parser, macros, name, value): @@ -257,7 +257,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_description(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -278,7 +278,7 @@ MyInterface: # Operation implementation @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_DICT_OR_STRING, + PERMUTATIONS, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_syntax_type(parser, macros, name, value): @@ -298,7 +298,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_implementation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -317,7 +317,7 @@ MyInterface: """, dict(name=name)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_implementation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -336,7 +336,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_STRING, + PERMUTATIONS, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_primary_syntax_type(parser, macros, name, value): @@ -357,7 +357,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_implementation_primary_short_form(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -376,7 +376,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_LIST, + PERMUTATIONS, data.NOT_A_LIST, counts=(2, 1) )) def test_type_interface_operation_implementation_dependencies_syntax_type(parser, macros, name, @@ -400,7 +400,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - CASES, data.NOT_A_STRING, + PERMUTATIONS, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_dependencies_syntax_element_type(parser, macros, @@ -424,7 +424,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_operation_implementation_dependencies_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -446,7 +446,7 @@ MyInterface: # Unicode [email protected]('macros,name', CASES) [email protected]('macros,name', PERMUTATIONS) def test_type_interface_unicode(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0
