More tests; improve parameter tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c953990f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c953990f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c953990f Branch: refs/heads/ARIA-1-parser-test-suite Commit: c953990f81d4a066d2a233bc1f9f2f3f80cbf3ad Parents: 62bb9f3 Author: Tal Liron <[email protected]> Authored: Thu Sep 28 15:13:28 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Thu Sep 28 15:13:28 2017 -0500 ---------------------------------------------------------------------- .../simple_v1_0/templates/common/test_copy.py | 0 .../templates/common/test_template_interface.py | 56 +-- .../common/test_template_parameters.py | 82 ++-- .../common/test_template_properties.py | 47 ++- .../templates/common/test_templates.py | 16 +- .../test_node_template_artifacts.py | 378 ++++++++---------- .../test_node_template_directives.py | 62 +++ .../simple_v1_0/templates/test_group.py | 14 +- .../simple_v1_0/templates/test_policy.py | 272 +++++++++++++ .../templates/test_policy_template.py | 272 ------------- .../types/common/test_type_interfaces.py | 44 ++- .../types/common/test_type_parameters.py | 382 ++---------------- .../types/common/test_type_properties.py | 383 +++++++++++++++++++ .../simple_v1_0/types/common/test_types.py | 30 +- .../types/node_type/test_node_type_artifacts.py | 277 -------------- .../node_type/test_node_type_capabilities.py | 3 - 16 files changed, 1068 insertions(+), 1250 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/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 new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/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 08025f6..2b78dfc 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 } -INTERFACE_SECTIONS = ( +CASES = ( ('main', 'node'), ('main', 'group'), ('main', 'relationship'), @@ -123,7 +123,7 @@ INTERFACE_SECTIONS = ( # Interfaces section @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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( - INTERFACE_SECTIONS, + CASES, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -354,7 +354,7 @@ MyInterface: value=value)).assert_success() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, data.NOT_A_LIST, counts=(2, 1) )) @@ -712,7 +712,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, + CASES, 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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( - INTERFACE_SECTIONS, + CASES, 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( - INTERFACE_SECTIONS, + CASES, data.PARAMETER_VALUES, counts=(2, 2) )) @@ -859,7 +859,7 @@ MyInterface: @pytest.mark.skip(reason='fix') [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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/c953990f/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 25cbfa0..aac6f88 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 @@ -14,12 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Unified testing for properties, attributes, and inputs. + +Additional tests for properties are in test_template_properties.py. +""" + import pytest from ... import data from ......mechanisms.utils import matrix +# Assigning to parameters defined at a type MAIN_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -31,6 +38,7 @@ MAIN_MACROS = """ {%- endmacro %} """ +# Assigning to parameters defined at a capability type CAPABILITY_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -49,6 +57,7 @@ capability_types: {%- endmacro %} """ +# Assigning to parameters defined at an artifact type ARTIFACT_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -66,6 +75,7 @@ artifact_types: {%- endmacro %} """ +# Assigning to inputs defined at an interface type INTERFACE_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -84,6 +94,7 @@ interface_types: {%- endmacro %} """ +# Assigning to inputs defined at an operation of an interface type OPERATION_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -104,6 +115,7 @@ interface_types: {%- endmacro %} """ +# Assigning to inputs defined (added/overriden) at an interface of the template's type LOCAL_INTERFACE_MACROS = """ {% macro additions() %} interface_types: @@ -122,6 +134,8 @@ interface_types: {%- endmacro %} """ +# Assigning to inputs defined (added/overriden) at an operation of an interface of the template's +# type LOCAL_OPERATION_MACROS = """ {% macro additions() %} interface_types: @@ -142,6 +156,7 @@ interface_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to parameters defined at a relationship type RELATIONSHIP_TYPE_MACROS = """ {% macro additions() %} capability_types: @@ -167,36 +182,7 @@ relationship_types: {%- endmacro %} """ -RELATIONSHIP_LOCAL_INTERFACE_MACROS = """ -{% macro additions() %} -capability_types: - MyType: {} -relationship_types: - MyType: {} -interface_types: - MyType: {} -{%- endmacro %} -{% macro type_parameters() %} - requirements: - - my_requirement: - capability: MyType - relationship: - type: MyType - interfaces: - MyInterface: - type: MyType - {{ parameter_section }}: {{ caller()|indent(18) }} -{%- endmacro %} -{% macro parameters() %} - requirements: - - my_requirement: - relationship: - interfaces: - MyInterface: - {{ parameter_section }}: {{ caller()|indent(20) }} -{%- endmacro %} -""" - +# At a relationship of a node template, assigning to inputs defined at an interface type RELATIONSHIP_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -227,6 +213,8 @@ interface_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to inputs defined at an operation of an interface +# type RELATIONSHIP_OPERATION_MACROS = """ {% macro additions() %} capability_types: @@ -259,6 +247,8 @@ interface_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to inputs defined (added/overriden) at an +# interface of a relationship type RELATIONSHIP_TYPE_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -289,6 +279,8 @@ relationship_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to inputs defined (added/overriden) at an +# operation of an interface of a relationship type RELATIONSHIP_TYPE_OPERATION_MACROS = """ {% macro additions() %} capability_types: @@ -321,6 +313,8 @@ relationship_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to inputs defined (added/overriden) at an +# interface of the relationship of the node type RELATIONSHIP_LOCAL_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -351,6 +345,8 @@ interface_types: {%- endmacro %} """ +# At a relationship of a node template, assigning to inputs defined (added/overriden) at an +# operation of an interface of the relationship of the node type RELATIONSHIP_LOCAL_OPERATION_MACROS = """ {% macro additions() %} capability_types: @@ -400,7 +396,7 @@ MACROS = { 'relationship-local-operation': RELATIONSHIP_LOCAL_OPERATION_MACROS } -PARAMETER_SECTIONS = ( +CASES = ( ('main', 'node', 'properties'), ('main', 'node', 'attributes'), ('main', 'group', 'properties'), @@ -435,7 +431,7 @@ PARAMETER_SECTIONS = ( # Parameters section @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, + CASES, data.NOT_A_DICT, counts=(3, 1) )) @@ -459,7 +455,7 @@ topology_template: parameter_section=parameter_section, value=value)).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -483,7 +479,7 @@ topology_template: # Parameter @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_template_parameter_missing(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -507,7 +503,7 @@ my_parameter: a value # Entry schema @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - PARAMETER_SECTIONS, + CASES, data.ENTRY_SCHEMA_VALUES, counts=(3, 1) )) @@ -543,7 +539,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - PARAMETER_SECTIONS, + CASES, data.ENTRY_SCHEMA_VALUES_BAD, counts=(3, 1) )) @@ -577,7 +573,7 @@ my_parameter: values=values), import_profile=True).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -607,7 +603,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -637,7 +633,7 @@ my_parameter: @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - PARAMETER_SECTIONS, + CASES, data.ENTRY_SCHEMA_VALUES, counts=(3, 1) )) @@ -673,7 +669,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') @pytest.mark.parametrize('macros,name,parameter_section,values', matrix( - PARAMETER_SECTIONS, + CASES, data.ENTRY_SCHEMA_VALUES_BAD, counts=(3, 1) )) @@ -707,7 +703,7 @@ my_parameter: values=values), import_profile=True).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -737,7 +733,7 @@ my_parameter: @pytest.mark.skip(reason='fix for capabilities') [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -768,7 +764,7 @@ my_parameter: # Unicode [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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/c953990f/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 105ec98..35fda49 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 @@ -14,28 +14,35 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Unified testing for properties. + +These tests are in addition to the common tests for parameters in test_template_parameters.py. +""" + import pytest -from .test_template_parameters import (MACROS, PARAMETER_SECTIONS) +from .test_template_parameters import (MACROS, CASES as PARAMETER_CASES) from ... import data from ......mechanisms.utils import matrix -PROPERTY_SECTIONS = tuple( - (macros, name) for macros, name, type_name in PARAMETER_SECTIONS if type_name == 'properties' +CASES = tuple( + (macros, name, parameter_section) + for macros, name, parameter_section in PARAMETER_CASES + if parameter_section != 'attributes' ) - # Required @pytest.mark.skip(reason='fix for relationships') [email protected]('macros,name,type_name', matrix( - PROPERTY_SECTIONS, [email protected]('macros,name,parameter_section,type_name', matrix( + CASES, data.PARAMETER_TYPE_NAMES, - counts=(2, 1) + counts=(3, 1) )) -def test_template_property_required(parser, macros, name, type_name): +def test_template_property_required(parser, macros, name, parameter_section, type_name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 {{- additions() }} @@ -57,16 +64,16 @@ topology_template: {%- call parameters() -%} {} {% endcall %} -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section, type_name=type_name)).assert_failure() [email protected]('macros,name,type_name', matrix( - PROPERTY_SECTIONS, [email protected]('macros,name,parameter_section,type_name', matrix( + CASES, data.PARAMETER_TYPE_NAMES, - counts=(2, 1) + counts=(3, 1) )) -def test_template_property_not_required(parser, macros, name, type_name): +def test_template_property_not_required(parser, macros, name, parameter_section, type_name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 {{- additions() }} @@ -89,16 +96,18 @@ topology_template: {%- call parameters() -%} {} {% endcall %} -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section, type_name=type_name)).assert_success() [email protected]('macros,name,type_name,value', matrix( - PROPERTY_SECTIONS, [email protected](reason='fix for relationship inputs') [email protected]('macros,name,parameter_section,type_name,value', matrix( + CASES, data.PARAMETER_VALUES, - counts=(2, 2) + counts=(3, 2) )) -def test_template_property_required_with_default(parser, macros, name, type_name, value): +def test_template_property_required_with_default(parser, macros, name, parameter_section, type_name, + value): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 {{- additions() }} @@ -121,5 +130,5 @@ topology_template: {%- call parameters() -%} {} {% endcall %} -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section='properties', +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section, type_name=type_name, value=value)).assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/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 ed6d553..d7a5142 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 -TEMPLATE_NAMES = ('node', 'group', 'relationship', 'policy') +CASES = ('node', 'group', 'relationship', 'policy') # Templates section @pytest.mark.parametrize('name,value', matrix( - TEMPLATE_NAMES, + CASES, 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', TEMPLATE_NAMES) [email protected]('name', CASES) def test_templates_section_syntax_empty(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -48,7 +48,7 @@ topology_template: # Template [email protected]('name', TEMPLATE_NAMES) [email protected]('name', CASES) def test_template_syntax_unsupported(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -62,7 +62,7 @@ topology_template: # Description @pytest.mark.parametrize('name,value', matrix( - TEMPLATE_NAMES, + CASES, data.NOT_A_STRING )) def test_template_description_syntax_type(parser, name, value): @@ -78,7 +78,7 @@ topology_template: # Type @pytest.mark.parametrize('name,value', matrix( - TEMPLATE_NAMES, + CASES, data.NOT_A_STRING )) def test_template_type_syntax_type(parser, name, value): @@ -90,7 +90,7 @@ topology_template: type: {{ value }} """, dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure() [email protected]('name', TEMPLATE_NAMES) [email protected]('name', CASES) def test_template_type_unknown(parser, name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 @@ -103,7 +103,7 @@ topology_template: # Unicode [email protected]('name', TEMPLATE_NAMES) [email protected]('name', CASES) 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/c953990f/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 322f3c2..70ca05a 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 @@ -18,323 +18,285 @@ import pytest from ... import data +from ......mechanisms.utils import matrix -# Artifacts section - [email protected]('value', data.NOT_A_DICT) -def test_node_template_artifacts_section_syntax_type(parser, value): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 +# Artifacts attached to a node template +TEMPLATE_MACROS = """ +{% macro artifacts() %} node_types: MyType: {} topology_template: node_templates: - my_template: + my_node: type: MyType - artifacts: {{ value }} + artifacts: {{ caller()|indent(8) }} +{% endmacro %} +""" + +# Artifacts attached to a node type +TYPE_MACROS = """ +{% macro artifacts() %} +node_types: + MyType: + artifacts: {{ caller()|indent(6) }} +{% endmacro %} +""" + +MACROS = { + 'template': TEMPLATE_MACROS, + 'type': TYPE_MACROS +} + +CASES = ( + 'template', + 'type' +) + + + +# Artifacts section + [email protected]('macros,value', matrix(CASES, 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 +{%- call artifacts() -%} +{{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifacts_section_syntax_empty(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifacts_section_syntax_empty(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: {} +{%- call artifacts() -%} +{} +{% endcall %} """).assert_success() # Artifact [email protected]('value', data.NOT_A_DICT) -def test_node_template_artifact_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: {{ value }} +{%- call artifacts() %} +my_artifact: {{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_syntax_unsupported(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_syntax_unsupported(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - unsupported: {} +{%- call artifacts() %} +my_artifact: + type: MyType + unsupported: {} +{% endcall %} """).assert_failure() -def test_node_template_artifact_syntax_empty(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_syntax_empty(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: {} # "type" and "file" are required +{%- call artifacts() %} +my_artifact: {} # "type" and "file" are required +{% endcall %} """).assert_failure() # Type [email protected]('value', data.NOT_A_STRING) -def test_node_template_artifact_type_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: {{ value }} - file: a file +{%- call artifacts() %} +my_artifact: + type: {{ value }} + file: a file +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_type_unknown(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_type_unknown(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: UnknownType - file: a file +{%- call artifacts() %} +my_artifact: + type: UnknownType + file: a file +{% endcall %} """).assert_failure() # File [email protected]('value', data.NOT_A_STRING) -def test_node_template_artifact_file_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: {{ value }} +{%- call artifacts() %} +my_artifact: + type: MyType + file: {{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_file(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_file(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file +{% endcall %} """).assert_success() # Description [email protected]('value', data.NOT_A_STRING) -def test_node_template_artifact_description_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - description: {{ value }} +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + description: {{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_description(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_description(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - description: a description +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + description: a description +{% endcall %} """).assert_success() # Repository [email protected]('value', data.NOT_A_STRING) -def test_node_template_artifact_repository_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - repository: {{ value }} +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + repository: {{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_repository_unknown(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_repository_unknown(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - repository: unknown +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + repository: unknown +{% endcall %} """).assert_failure() -def test_node_template_artifact_repository(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_repository(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 repositories: my_repository: url: a url artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - repository: my_repository +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + repository: my_repository +{% endcall %} """).assert_success() # Deploy path [email protected]('value', data.NOT_A_STRING) -def test_node_template_artifact_deploy_path_syntax_type(parser, value): - parser.parse_literal(""" [email protected]('macros,value', matrix(CASES, 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 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - deploy_path: {{ value }} +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + deploy_path: {{ value }} +{% endcall %} """, dict(value=value)).assert_failure() -def test_node_template_artifact_deploy_path(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_deploy_path(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 artifact_types: MyType: {} -node_types: - MyType: {} -topology_template: - node_templates: - my_template: - type: MyType - artifacts: - my_artifact: - type: MyType - file: a file - deploy_path: a path +{%- call artifacts() %} +my_artifact: + type: MyType + file: a file + deploy_path: a path +{% endcall %} """).assert_success() # Unicode -def test_node_template_artifact_unicode(parser): - parser.parse_literal(""" [email protected]('macros', CASES) +def test_node_template_artifact_unicode(parser, macros): + parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 repositories: ç¥è庫: url: ç¶²å artifact_types: é¡å: {} -node_types: - é¡å: {} -topology_template: - node_templates: - 模æ¿: - type: é¡å - artifacts: - ç¥å¨: - type: é¡å - file: æä»¶ - repository: ç¥è庫 - deploy_path: è·¯å¾ +{%- call artifacts() %} +ç¥å¨: + type: é¡å + file: æä»¶ + repository: ç¥è庫 + deploy_path: è·¯å¾ +{% endcall %} """).assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py index 8ca2ef7..5ea2c13 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/node_template/test_node_template_directives.py @@ -13,3 +13,65 @@ # 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 + + [email protected]('value', data.NOT_A_LIST) +def test_node_template_directives_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + node_templates: + my_node: + type: MyType + directives: {{ value }} +""", dict(value=value)).assert_failure() + + [email protected]('value', data.NOT_A_STRING) +def test_node_template_directives_syntax_element_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + node_templates: + my_node: + type: MyType + directives: [ {{ value }} ] +""", dict(value=value)).assert_failure() + + +def test_node_template_directives_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + node_templates: + my_node: + type: MyType + directives: [] +""").assert_success() + + +# Unicode + +def test_node_template_directives_unicode(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + é¡å: {} +topology_template: + node_templates: + ç¯é»: + type: é¡å + directives: + - æç¤ºä¸ + - æç¤ºäº +""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py index fc7a7d4..8fd37c4 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_group.py @@ -29,7 +29,7 @@ group_types: MyType: {} topology_template: groups: - my_policy: + my_group: type: MyType members: {{ value }} """, dict(value=value)).assert_failure() @@ -43,7 +43,7 @@ group_types: MyType: {} topology_template: groups: - my_policy: + my_group: type: MyType members: [ {{ value }} ] """, dict(value=value)).assert_failure() @@ -56,7 +56,7 @@ group_types: MyType: {} topology_template: groups: - my_policy: + my_group: type: MyType members: [] """).assert_success() @@ -78,7 +78,7 @@ topology_template: my_node2: type: MyType2 groups: - my_policy: + my_group: type: MyType members: [ my_node1, my_node2 ] """).assert_success() @@ -99,7 +99,7 @@ topology_template: my_node: type: MyType2 groups: - my_policy: + my_group: type: MyType members: [ my_node ] """).assert_success() @@ -120,7 +120,7 @@ topology_template: my_node: type: MyType1 groups: - my_policy: + my_group: type: MyType members: [ my_node ] """).assert_failure() @@ -133,7 +133,7 @@ group_types: MyType: {} topology_template: groups: - my_policy: + my_group: type: MyType members: [ unknown ] """).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py new file mode 100644 index 0000000..28ee483 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy.py @@ -0,0 +1,272 @@ +# -*- 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 + + +# Targets + [email protected]('value', data.NOT_A_LIST) +def test_policy_targets_syntax_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: {} +topology_template: + policies: + my_policy: + type: MyType + targets: {{ value }} +""", dict(value=value)).assert_failure() + + [email protected]('value', data.NOT_A_STRING) +def test_policy_targets_syntax_element_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: {} +topology_template: + policies: + my_policy: + type: MyType + targets: [ {{ value }} ] +""", dict(value=value)).assert_failure() + + +def test_policy_targets_syntax_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: {} +topology_template: + policies: + my_policy: + type: MyType + targets: [] +""").assert_success() + + +def test_policy_targets_nodes(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType1: {} + MyType2: {} +policy_types: + MyType: + targets: [ MyType1, MyType2 ] +topology_template: + node_templates: + my_node1: + type: MyType1 + my_node2: + type: MyType2 + policies: + my_policy: + type: MyType + targets: [ my_node1, my_node2 ] +""").assert_success() + + +def test_policy_targets_nodes_derived(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType1: {} + MyType2: + derived_from: MyType1 +policy_types: + MyType: + targets: [ MyType1 ] +topology_template: + node_templates: + my_node: + type: MyType2 + policies: + my_policy: + type: MyType + targets: [ my_node ] +""").assert_success() + + +def test_policy_targets_nodes_derived_bad(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType1: {} + MyType2: + derived_from: MyType1 +policy_types: + MyType: + targets: [ MyType2 ] +topology_template: + node_templates: + my_node: + type: MyType1 + policies: + my_policy: + type: MyType + targets: [ my_node ] +""").assert_failure() + + +def test_policy_targets_groups(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +group_types: + MyType1: {} + MyType2: {} +policy_types: + MyType: + targets: [ MyType1, MyType2 ] +topology_template: + groups: + my_group1: + type: MyType1 + my_group2: + type: MyType2 + policies: + my_policy: + type: MyType + targets: [ my_group1, my_group2 ] +""").assert_success() + + +def test_policy_targets_groups_derived(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +group_types: + MyType1: {} + MyType2: + derived_from: MyType1 +policy_types: + MyType: + targets: [ MyType1 ] +topology_template: + groups: + my_group: + type: MyType2 + policies: + my_policy: + type: MyType + targets: [ my_group ] +""").assert_success() + + +def test_policy_targets_groups_derived_bad(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +group_types: + MyType1: {} + MyType2: + derived_from: MyType1 +policy_types: + MyType: + targets: [ MyType2 ] +topology_template: + groups: + my_group: + type: MyType1 + policies: + my_policy: + type: MyType + targets: [ my_group ] +""").assert_failure() + + +def test_policy_targets_nodes_and_groups(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyNodeType: {} +group_types: + MyGroupType: {} +policy_types: + MyType: + targets: [ MyNodeType, MyGroupType ] +topology_template: + node_templates: + my_node: + type: MyNodeType + groups: + my_group: + type: MyGroupType + policies: + my_policy: + type: MyType + targets: [ my_node, my_group ] +""").assert_success() + + +def test_policy_targets_ambiguous(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyNodeType: {} +group_types: + MyGroupType: {} +policy_types: + MyType: + targets: [ MyNodeType, MyGroupType ] +topology_template: + node_templates: + my_template: + type: MyNodeType + groups: + my_template: + type: MyGroupType + policies: + my_policy: + type: MyType + targets: [ my_template ] +""").assert_success() + + +def test_policy_targets_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: {} +topology_template: + policies: + my_policy: + type: MyType + targets: [ unknown ] +""").assert_failure() + + +# Unicode + +def test_policy_unicode(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + é¡å: {} +policy_types: + é¡å: + targets: [ é¡å ] +topology_template: + node_templates: + ç¯é»: + type: é¡å + policies: + æ¿ç: + type: é¡å + targets: [ ç¯é» ] +""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py deleted file mode 100644 index e14534b..0000000 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_policy_template.py +++ /dev/null @@ -1,272 +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 - - -# Targets - [email protected]('value', data.NOT_A_LIST) -def test_policy_template_targets_syntax_type(parser, value): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -policy_types: - MyType: {} -topology_template: - policies: - my_policy: - type: MyType - targets: {{ value }} -""", dict(value=value)).assert_failure() - - [email protected]('value', data.NOT_A_STRING) -def test_policy_template_targets_syntax_element_type(parser, value): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -policy_types: - MyType: {} -topology_template: - policies: - my_policy: - type: MyType - targets: [ {{ value }} ] -""", dict(value=value)).assert_failure() - - -def test_policy_template_targets_syntax_empty(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -policy_types: - MyType: {} -topology_template: - policies: - my_policy: - type: MyType - targets: [] -""").assert_success() - - -def test_policy_template_targets_nodes(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType1: {} - MyType2: {} -policy_types: - MyType: - targets: [ MyType1, MyType2 ] -topology_template: - node_templates: - my_node1: - type: MyType1 - my_node2: - type: MyType2 - policies: - my_policy: - type: MyType - targets: [ my_node1, my_node2 ] -""").assert_success() - - -def test_policy_template_targets_nodes_derived(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType1: {} - MyType2: - derived_from: MyType1 -policy_types: - MyType: - targets: [ MyType1 ] -topology_template: - node_templates: - my_node: - type: MyType2 - policies: - my_policy: - type: MyType - targets: [ my_node ] -""").assert_success() - - -def test_policy_template_targets_nodes_derived_bad(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyType1: {} - MyType2: - derived_from: MyType1 -policy_types: - MyType: - targets: [ MyType2 ] -topology_template: - node_templates: - my_node: - type: MyType1 - policies: - my_policy: - type: MyType - targets: [ my_node ] -""").assert_failure() - - -def test_policy_template_targets_groups(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -group_types: - MyType1: {} - MyType2: {} -policy_types: - MyType: - targets: [ MyType1, MyType2 ] -topology_template: - groups: - my_group1: - type: MyType1 - my_group2: - type: MyType2 - policies: - my_policy: - type: MyType - targets: [ my_group1, my_group2 ] -""").assert_success() - - -def test_policy_template_targets_groups_derived(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -group_types: - MyType1: {} - MyType2: - derived_from: MyType1 -policy_types: - MyType: - targets: [ MyType1 ] -topology_template: - groups: - my_group: - type: MyType2 - policies: - my_policy: - type: MyType - targets: [ my_group ] -""").assert_success() - - -def test_policy_template_targets_groups_derived_bad(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -group_types: - MyType1: {} - MyType2: - derived_from: MyType1 -policy_types: - MyType: - targets: [ MyType2 ] -topology_template: - groups: - my_group: - type: MyType1 - policies: - my_policy: - type: MyType - targets: [ my_group ] -""").assert_failure() - - -def test_policy_template_targets_nodes_and_groups(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyNodeType: {} -group_types: - MyGroupType: {} -policy_types: - MyType: - targets: [ MyNodeType, MyGroupType ] -topology_template: - node_templates: - my_node: - type: MyNodeType - groups: - my_group: - type: MyGroupType - policies: - my_policy: - type: MyType - targets: [ my_node, my_group ] -""").assert_success() - - -def test_policy_template_targets_ambiguous(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - MyNodeType: {} -group_types: - MyGroupType: {} -policy_types: - MyType: - targets: [ MyNodeType, MyGroupType ] -topology_template: - node_templates: - my_template: - type: MyNodeType - groups: - my_template: - type: MyGroupType - policies: - my_policy: - type: MyType - targets: [ my_template ] -""").assert_success() - - -def test_policy_template_targets_unknown(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -policy_types: - MyType: {} -topology_template: - policies: - my_policy: - type: MyType - targets: [ unknown ] -""").assert_failure() - - -# Unicode - -def test_policy_template_unicode(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -node_types: - é¡å: {} -policy_types: - é¡å: - targets: [ é¡å ] -topology_template: - node_templates: - ç¯é»: - type: é¡å - policies: - æ¿ç: - type: é¡å - targets: [ ç¯é» ] -""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c953990f/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 85ca47b..463dd9a 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 @@ -20,6 +20,7 @@ from ... import data from ......mechanisms.utils import matrix +# Interfaces defined at a type MAIN_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -28,6 +29,7 @@ MAIN_MACROS = """ {%- endmacro %} """ +# Interfaces defined (added/overriden) at a relationship of a requirement within a node type RELATIONSHIP_MACROS = """ {% macro additions() %} capability_types: @@ -50,7 +52,7 @@ MACROS = { 'relationship': RELATIONSHIP_MACROS } -INTERFACE_SECTIONS = ( +CASES = ( ('main', 'node'), ('main', 'group'), ('main', 'relationship'), @@ -61,7 +63,7 @@ INTERFACE_SECTIONS = ( # Interfaces section @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_DICT, + CASES, data.NOT_A_DICT, counts=(2, 1) )) def test_type_interfaces_section_syntax_type(parser, macros, name, value): @@ -78,7 +80,7 @@ interface_types: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interfaces_section_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -94,7 +96,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Interface @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_DICT, + CASES, data.NOT_A_DICT, counts=(2, 1) )) def test_type_interface_syntax_type(parser, macros, name, value): @@ -111,7 +113,7 @@ MyInterface: {{ value }} """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -126,7 +128,7 @@ MyInterface: {} # "type" is required # Type [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_type_override(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -151,7 +153,7 @@ MyInterface: @pytest.mark.skip(reason='fix for node.relationship') [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_type_override_bad(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -178,7 +180,7 @@ MyInterface: # Operation @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_DICT_OR_STRING, + CASES, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) def test_type_interface_operation_syntax_type(parser, macros, name, value): @@ -197,7 +199,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_operation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -215,7 +217,7 @@ MyInterface: """, dict(name=name)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_operation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -235,7 +237,7 @@ MyInterface: # Operation description @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_STRING, + CASES, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_description_syntax_type(parser, macros, name, value): @@ -255,7 +257,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_operation_description(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -276,7 +278,7 @@ MyInterface: # Operation implementation @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_DICT_OR_STRING, + CASES, data.NOT_A_DICT_OR_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_syntax_type(parser, macros, name, value): @@ -296,7 +298,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_operation_implementation_syntax_unsupported(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -315,7 +317,7 @@ MyInterface: """, dict(name=name)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_interface_operation_implementation_syntax_empty(parser, macros, name): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -334,7 +336,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_STRING, + CASES, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_primary_syntax_type(parser, macros, name, value): @@ -355,7 +357,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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 @@ -374,7 +376,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_LIST, + CASES, data.NOT_A_LIST, counts=(2, 1) )) def test_type_interface_operation_implementation_dependencies_syntax_type(parser, macros, name, @@ -398,7 +400,7 @@ MyInterface: @pytest.mark.parametrize('macros,name,value', matrix( - INTERFACE_SECTIONS, data.NOT_A_STRING, + CASES, data.NOT_A_STRING, counts=(2, 1) )) def test_type_interface_operation_implementation_dependencies_syntax_element_type(parser, macros, @@ -422,7 +424,7 @@ MyInterface: """, dict(name=name, value=value)).assert_failure() [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) 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 @@ -444,7 +446,7 @@ MyInterface: # Unicode [email protected]('macros,name', INTERFACE_SECTIONS) [email protected]('macros,name', CASES) def test_type_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/c953990f/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 e03c43f..38e2023 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 @@ -14,12 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Unified testing for properties, attributes, and inputs. + +Additional tests for properties are in test_type_properties.py. + +Note: artifact definitions within node types use parameter assignments rather than definitions, and +thus are tested not here but under test_template_parameters.py. +""" + import pytest from ... import data from ......mechanisms.utils import matrix +# Defining parameters at a type MAIN_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -28,6 +38,7 @@ MAIN_MACROS = """ {%- endmacro %} """ +# Defining parameters at a nested type (e.g. inputs of an operation within an interface type) NESTED_MACROS = """ {% macro additions() %} {%- endmacro %} @@ -37,6 +48,7 @@ NESTED_MACROS = """ {%- endmacro %} """ +# Defining inputs at an interface of a type INTERFACE_MACROS = """ {% macro additions() %} interface_types: @@ -50,6 +62,7 @@ interface_types: {%- endmacro %} """ +# Defining inputs at an operation of an interface of a type OPERATION_MACROS = """ {% macro additions() %} interface_types: @@ -64,6 +77,7 @@ interface_types: {%- endmacro %} """ +# Defining inputs at an interface of a relationship of a requirement of a node type RELATIONSHIP_INTERFACE_MACROS = """ {% macro additions() %} capability_types: @@ -86,6 +100,7 @@ interface_types: {%- endmacro %} """ +# Defining inputs at an operation of an interface of a relationship of a requirement of a node type RELATIONSHIP_OPERATION_MACROS = """ {% macro additions() %} capability_types: @@ -109,6 +124,7 @@ interface_types: {%- endmacro %} """ +# Defining parameters at a capability of a node type CAPABILITY_MACROS = """ {% macro additions() %} capability_types: @@ -132,7 +148,7 @@ MACROS = { 'capability': CAPABILITY_MACROS } -PARAMETER_SECTIONS = ( +CASES = ( ('main', 'node', 'properties'), ('main', 'node', 'attributes'), ('main', 'group', 'properties'), @@ -157,32 +173,11 @@ PARAMETER_SECTIONS = ( ('capability', 'node', 'attributes') ) -PROPERTY_SECTIONS = ( - ('main', 'node', 'properties'), - ('main', 'group', 'properties'), - ('main', 'relationship', 'properties'), - ('main', 'capability', 'properties'), - ('main', 'policy', 'properties'), - ('main', 'interface', 'inputs'), - ('main', 'artifact', 'properties'), - ('main', 'data', 'properties'), - ('nested', 'interface', 'inputs'), - ('interface', 'node', 'inputs'), - ('interface', 'group', 'inputs'), - ('interface', 'relationship', 'inputs'), - ('operation', 'node', 'inputs'), - ('operation', 'group', 'inputs'), - ('operation', 'relationship', 'inputs'), - ('relationship-interface', 'node', 'inputs'), - ('relationship-operation', 'node', 'inputs'), - ('capability', 'node', 'properties') -) - # Parameters section @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, + CASES, data.NOT_A_DICT, counts=(3, 1) )) @@ -198,7 +193,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 """, dict(name=name, parameter_section=parameter_section, value=value)).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameters_section_syntax_empty(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -214,7 +209,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 # Parameter @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, + CASES, data.NOT_A_DICT, counts=(3, 1) )) @@ -230,7 +225,7 @@ my_parameter: {{ value }} """, dict(name=name, parameter_section=parameter_section, value=value)).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_syntax_empty(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -243,7 +238,7 @@ my_parameter: {} # type is required """, dict(name=name, parameter_section=parameter_section)).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_syntax_unsupported(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -261,7 +256,7 @@ my_parameter: # Description @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, + CASES, data.NOT_A_STRING, counts=(3, 1) )) @@ -279,7 +274,7 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section, value=value)).assert_failure() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_description(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -296,7 +291,7 @@ my_parameter: # Default [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_default(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -311,7 +306,7 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section)).assert_success() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_default_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -326,45 +321,10 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section)).assert_failure() -# Required - [email protected]('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, - data.NOT_A_BOOL, - counts=(3, 1) -)) -def test_type_parameter_required_syntax_type(parser, macros, name, parameter_section, value): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - required: {{ value }} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure() - [email protected]('macros,name,parameter_section', PROPERTY_SECTIONS) -def test_type_parameter_required(parser, macros, name, parameter_section): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - required: true -{% endcall %} -""", dict(name=name, parameter_section=parameter_section)).assert_success() - - # Status @pytest.mark.parametrize('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, + CASES, data.STATUSES, counts=(3, 1) )) @@ -382,7 +342,7 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section, value=value)).assert_success() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_status_bad(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -397,269 +357,9 @@ my_parameter: """, dict(name=name, parameter_section=parameter_section)).assert_failure() -# Constraints - [email protected]('macros,name,parameter_section,value', matrix( - PARAMETER_SECTIONS, - data.NOT_A_LIST, - counts=(3, 1) -)) -def test_type_parameter_constraints_syntax_type(parser, macros, name, parameter_section, value): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: {{ value }} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure() - - [email protected]('macros,name,parameter_section', PROPERTY_SECTIONS) -def test_type_parameter_constraints_syntax_empty(parser, macros, name, parameter_section): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: [] -{% endcall %} -""", dict(name=name, parameter_section=parameter_section)).assert_success() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_VALUE, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_value(parser, macros, name, parameter_section, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyDataType: - properties: - my_field: - type: string -{%- if name != 'data' %} -{{ name }}_types: -{%- endif %} - MyType: -{%- call parameters() %} -my_parameter: - type: MyDataType - constraints: - - {{ constraint }}: {my_field: a string} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_VALUE_LIST, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_value_list(parser, macros, name, parameter_section, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyDataType: - properties: - my_field: - type: string -{%- if name != 'data' %} -{{ name }}_types: -{%- endif %} - MyType: -{%- call parameters() %} -my_parameter: - type: MyDataType - constraints: - - {{ constraint }}: - - {my_field: string one} - - {my_field: string two} - - {my_field: string three} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_VALUE_RANGE, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_value_range(parser, macros, name, parameter_section, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyDataType: - properties: - my_field: - type: string -{%- if name != 'data' %} -{{ name }}_types: -{%- endif %} - MyType: -{%- call parameters() %} -my_parameter: - type: MyDataType - constraints: - - {{ constraint }}: - - {my_field: string a} - - {my_field: string b} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_VALUE_RANGE, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_value_range_too_many(parser, macros, name, - parameter_section, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyDataType: - properties: - my_field: - type: string -{%- if name != 'data' %} -{{ name }}_types: -{%- endif %} - MyType: -{%- call parameters() %} -my_parameter: - type: MyDataType - constraints: - - {{ constraint }}: - - {my_field: string a} - - {my_field: string b} - - {my_field: string c} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_VALUE_RANGE, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_value_range_invalid(macros, parser, name, - parameter_section, constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -data_types: - MyDataType: - properties: - my_field: - type: string -{%- if name != 'data' %} -{{ name }}_types: -{%- endif %} - MyType: -{%- call parameters() %} -my_parameter: - type: MyDataType - constraints: - - {{ constraint }}: - - {my_field: string b} - - {my_field: string a} -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure() - - [email protected]('macros,name,parameter_section', PROPERTY_SECTIONS) -def test_type_parameter_constraints_pattern(parser, macros, name, parameter_section): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: - - pattern: ^pattern$ -{% endcall %} -""", dict(name=name, parameter_section=parameter_section)).assert_success() - - [email protected]('macros,name,parameter_section', PROPERTY_SECTIONS) -def test_type_parameter_constraints_pattern_bad(parser, macros, name, parameter_section): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: - - pattern: ( -{% endcall %} -""", dict(name=name, parameter_section=parameter_section)).assert_failure() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_NON_NEGATIVE_INT, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_integer(parser, macros, name, parameter_section, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: - - {{ constraint }}: 1 -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success() - - [email protected]('macros,name,parameter_section,constraint', matrix( - PROPERTY_SECTIONS, - data.CONSTRAINTS_WITH_NON_NEGATIVE_INT, - counts=(3, 1) -)) -def test_type_parameter_constraints_with_integer_bad(parser, macros, name, parameter_section, - constraint): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - MyType: -{%- call parameters() %} -my_parameter: - type: string - constraints: - - {{ constraint }}: -1 -{% endcall %} -""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure() - - # Overriding [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_add(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -679,7 +379,7 @@ my_parameter2: """, dict(name=name, parameter_section=parameter_section)).assert_success() [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_add_default(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -701,7 +401,7 @@ my_parameter: @pytest.mark.skip(reason='fix for node.capability and node.relationship') [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_type_override(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -728,7 +428,7 @@ my_parameter: @pytest.mark.skip(reason='fix for node.capability and node.relationship') [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) 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 @@ -756,7 +456,7 @@ my_parameter: # Unicode [email protected]('macros,name,parameter_section', PARAMETER_SECTIONS) [email protected]('macros,name,parameter_section', CASES) def test_type_parameter_unicode(parser, macros, name, parameter_section): parser.parse_literal(MACROS[macros] + """ tosca_definitions_version: tosca_simple_yaml_1_0 @@ -771,19 +471,3 @@ tosca_definitions_version: tosca_simple_yaml_1_0 status: supported {% endcall %} """, dict(name=name, parameter_section=parameter_section)).assert_success() - - [email protected]('macros,name,parameter_section', PROPERTY_SECTIONS) -def test_type_parameter_constraints_pattern_unicode(parser, macros, name, parameter_section): - parser.parse_literal(MACROS[macros] + """ -tosca_definitions_version: tosca_simple_yaml_1_0 -{{- additions() }} -{{ name }}_types: - é¡å: -{%- call parameters() %} -忏: - type: string - constraints: - - pattern: ^模å¼$ -{% endcall %} -""", dict(name=name, parameter_section=parameter_section)).assert_success()
