http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py new file mode 100644 index 0000000..97bf101 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_policy_type.py @@ -0,0 +1,121 @@ +# -*- 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_type_targets_wrong_yaml_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: + targets: {{ value }} +""", dict(value=value)).assert_failure() + + [email protected]('value', data.NOT_A_STRING) +def test_policy_type_targets_element_wrong_yaml_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: + targets: [ {{ value }} ] +""", dict(value=value)).assert_failure() + + +def test_policy_type_targets_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: + targets: [] +""").assert_success() + + +def test_policy_type_targets_nodes(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType1: {} + MyType2: {} +policy_types: + MyType: + targets: [ MyType1, MyType2 ] +""").assert_success() + + +def test_policy_type_targets_groups(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +group_types: + MyType1: {} + MyType2: {} +policy_types: + MyType: + targets: [ MyType1, MyType2 ] +""").assert_success() + + +def test_policy_type_targets_nodes_and_groups(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType1: {} +group_types: + MyType2: {} +policy_types: + MyType: + targets: [ MyType1, MyType2 ] +""").assert_success() + + +def test_policy_type_targets_ambiguous(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +group_types: + MyType: {} +policy_types: + MyType: + targets: [ MyType ] +""").assert_success() + + +def test_policy_type_targets_unicode(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + é¡åä¸: {} + é¡åäº: {} +policy_types: + é¡å: + targets: [ é¡åä¸, é¡åäº ] +""").assert_success() + + +def test_policy_type_targets_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +policy_types: + MyType: + targets: [ UnknownType ] +""").assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py new file mode 100644 index 0000000..b0d8ab0 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_relationship_type.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from .. import data + + +# Valid target types + [email protected]('value', data.NOT_A_LIST) +def test_relationship_type_valid_target_types_wrong_yaml_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +relationship_types: + MyType: + valid_target_types: {{ value }} +""", dict(value=value)).assert_failure() + + [email protected]('value', data.NOT_A_STRING) +def test_relationship_type_valid_target_types_element_wrong_yaml_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +relationship_types: + MyType: + valid_target_types: [ {{ value }} ] +""", dict(value=value)).assert_failure() + + +def test_relationship_type_valid_target_types_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +relationship_types: + MyType: + valid_target_types: [] +""").assert_success() + + +def test_relationship_type_valid_target_types(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + MyType1: {} + MyType2: {} +relationship_types: + MyType: + valid_target_types: [ MyType1, MyType2 ] +""").assert_success() + + +def test_relationship_type_valid_target_types_unicode(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +capability_types: + é¡åä¸: {} + é¡åäº: {} +relationship_types: + é¡å: + valid_target_types: [ é¡åä¸, é¡åäº ] +""").assert_success() + + +def test_relationship_type_valid_target_types_unknown(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +relationship_types: + MyType: + valid_target_types: [ UnknownType ] +""").assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py new file mode 100644 index 0000000..c4283bd --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_interfaces.py @@ -0,0 +1,438 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +""" +Developer note: make sure that these tests mirror those in +test_node_type_relationship_interfaces.py. +""" + +import itertools + +import pytest + +from .. import data + + +TYPE_NAMES = ('node', 'relationship', 'group') + + +# Syntax + [email protected]('name,value', itertools.product( + TYPE_NAMES, + data.NOT_A_DICT +)) +def test_type_interface_wrong_yaml_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: {{ value }} +""", dict(name=name, value=value)).assert_failure() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_empty(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + interfaces: + my_interface: {} # "type" is required +""", dict(name=name)).assert_failure() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_fields(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + inputs: {} + my_operation1: {} + my_operation2: {} +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_fields_unicode(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + é¡å: {} +{{ name }}_types: + é¡å: + interfaces: + æ¥å£: + type: é¡å + æè¡: + implementation: å±¥è¡ +""", dict(name=name)).assert_success() + + +# Type + [email protected](reason='fixed in ARIA-351') [email protected]('name', TYPE_NAMES) +def test_type_interface_type_override(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType1: {} + MyType2: + derived_form: MyType1 +{{ name }}_types: + MyType1: + interfaces: + my_interface: + type: MyType1 + MyType2: + derived_from: MyType1 + interfaces: + my_interface: + type: MyType2 +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_type_override_bad(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType1: {} + MyType2: + derived_form: MyType1 +{{ name }}_types: + MyType1: + interfaces: + my_interface: + type: MyType2 + MyType2: + derived_from: MyType1 + interfaces: + my_interface: + type: MyType1 +""", dict(name=name)).assert_failure() + + +# Interface inputs + [email protected]('name', TYPE_NAMES) +def test_type_interface_inputs_add(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: + inputs: + my_input1: + type: string +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + inputs: + my_input2: + type: string +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_inputs_type_override_same(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: + inputs: + my_input: + type: string +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + inputs: + my_input: + type: string +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_inputs_type_override_derived(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +interface_types: + MyType: + inputs: + my_input: + type: MyType1 +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + inputs: + my_input: + type: MyType2 +""", dict(name=name)).assert_success() + + [email protected](reason='fix') [email protected]('name', TYPE_NAMES) +def test_type_interface_inputs_type_override_bad(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +interface_types: + MyType: + inputs: + my_input: + type: MyType2 +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + inputs: + my_input: + type: MyType1 +""", dict(name=name)).assert_failure() + + +# Operations + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_empty(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: {} +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_fields(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + description: a description + implementation: {} + inputs: {} +""", dict(name=name)).assert_success() + + +# Operation implementation + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_implementation_short_form(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + implementation: an implementation +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_implementation_long_form(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + implementation: + primary: an implementation + dependencies: + - a dependency + - another dependency +""", dict(name=name)).assert_success() + + [email protected]('name,value', itertools.product( + TYPE_NAMES, + data.NOT_A_STRING +)) +def test_type_interface_operation_implementation_wrong_yaml_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + implementation: + primary: {{ value }} +""", dict(name=name, value=value)).assert_failure() + + [email protected]('name,value', itertools.product( + TYPE_NAMES, + data.NOT_A_STRING +)) +def test_type_interface_operation_dependencies_wrong_yaml_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: {} +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + implementation: + primary: an implementation + dependencies: + - {{ value }} +""", dict(name=name, value=value)).assert_failure() + + +# Operation inputs + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_inputs_add(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: + inputs: + my_input: + type: string +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + inputs: + my_input: + type: string +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_inputs_override_same_type(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +interface_types: + MyType: + inputs: + my_input: + type: string +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + inputs: + my_input: + type: string +""", dict(name=name)).assert_success() + + [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_inputs_override_derived_type(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +interface_types: + MyType: + inputs: + my_input: + type: MyType1 +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + inputs: + my_input: + type: MyType2 +""", dict(name=name)).assert_success() + + [email protected](reason='fix') [email protected]('name', TYPE_NAMES) +def test_type_interface_operation_inputs_override_bad(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +interface_types: + MyType: + inputs: + my_input: + type: MyType2 +{{ name }}_types: + MyType: + interfaces: + my_interface: + type: MyType + my_operation: + inputs: + my_input: + type: MyType1 +""", dict(name=name)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py new file mode 100644 index 0000000..bb65bbd --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_type_parameters.py @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import itertools + +import pytest + +from .. import data + + +# Fields + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_fields(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + {{ parameter_section }}: + my_parameter: + type: string + description: a description + default: a value + status: supported +""", dict(name=name, parameter_section=parameter_section)).assert_success() + + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_fields_unicode(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + {{ parameter_section }}: + 忏: + type: string + description: æè¿° + default: å¼ + status: supported +""", dict(name=name, parameter_section=parameter_section)).assert_success() + + +# Status + [email protected]( + 'name,parameter_section,value', + ((s[0], s[1], v) + for s, v in itertools.product(data.PARAMETER_SECTIONS, data.STATUSES)) +) +def test_node_type_parameter_status(parser, name, parameter_section, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + {{ parameter_section }}: + my_parameter: + type: string + status: {{ value }} +""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success() + + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_status_bad(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + {{ parameter_section }}: + my_parameter: + type: string + status: not a status +""", dict(name=name, parameter_section=parameter_section)).assert_failure() + + +# Overriding + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_add(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType1: + {{ parameter_section }}: + my_parameter1: + type: string + MyType2: + derived_from: MyType1 + {{ parameter_section }}: + my_parameter2: + type: string +""", dict(name=name, parameter_section=parameter_section)).assert_success() + + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_add_default(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType1: + {{ parameter_section }}: + my_parameter: + type: string + MyType2: + derived_from: MyType1 + {{ parameter_section }}: + my_parameter: + type: string + default: my value +""", dict(name=name, parameter_section=parameter_section)).assert_success() + + [email protected](reason='fixed in ARIA-351') [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_type_override(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +{{ name }}_types: + MyType1: + {{ parameter_section }}: + my_parameter: + type: MyType1 + MyType2: + derived_from: MyType1 + {{ parameter_section }}: + my_parameter: + type: MyType2 +""", dict(name=name, parameter_section=parameter_section)).assert_success() + + [email protected]('name,parameter_section', data.PARAMETER_SECTIONS) +def test_node_type_parameter_type_override_bad(parser, name, parameter_section): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType1: {} + MyType2: + derived_from: MyType1 +{{ name }}_types: + MyType1: + {{ parameter_section }}: + my_parameter: + type: MyType2 + MyType2: + derived_from: MyType1 + {{ parameter_section }}: + my_parameter: + type: MyType1 +""", dict(name=name, parameter_section=parameter_section)).assert_failure() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/75225e88/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py new file mode 100644 index 0000000..8e2f26f --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_types.py @@ -0,0 +1,152 @@ +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import itertools + +import pytest + +from .. import data + + +# Syntax + [email protected]('name,value', itertools.product( + data.TYPE_NAMES, + data.NOT_A_DICT +)) +def test_type_wrong_yaml_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: {{ value }} +""", dict(name=name, value=value)).assert_failure() + + [email protected]('name', data.TYPE_NAMES) +def test_type_empty(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: {} +""", dict(name=name)).assert_success() + + [email protected]('name,value', itertools.product( + data.TYPE_NAMES, + data.NOT_A_STRING +)) +def test_type_derived_from_wrong_yaml_type(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: {{ value }} +""", dict(name=name, value=value)).assert_failure() + + +# Derivation + [email protected]('name', data.TYPE_NAMES) +def test_type_derived_from_unknown(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: UnknownType +""", dict(name=name)).assert_failure() + + [email protected]('name', data.TYPE_NAMES) +def test_type_derived_from_null(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: null +""", dict(name=name)).assert_failure() + + [email protected]('name', data.TYPE_NAMES) +def test_type_derived_from_self(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: MyType +""", dict(name=name)).assert_failure() + + [email protected]('name', data.TYPE_NAMES) +def test_type_derived_from_circular(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType1: + derived_from: MyType3 + MyType2: + derived_from: MyType1 + MyType3: + derived_from: MyType2 +""", dict(name=name)).assert_failure() + + [email protected]('name', data.TYPE_NAMES) +def test_type_derived_from_root(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: tosca.{{ plural }}.Root +""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success() + + +# Common fields + [email protected]('name', data.TYPE_NAMES) +def test_type_fields(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + derived_from: tosca.{{ plural }}.Root + version: 1.0.0 + description: a description +""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success() + + [email protected]('name', data.TYPE_NAMES) +def test_type_fields_unicode(parser, name): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + é¡å: + derived_from: tosca.{{ plural }}.Root + version: 1.0.0.è© å調-10 + description: æè¿° +""", dict(name=name, plural=data.TYPE_NAME_PLURAL[name])).assert_success() + + [email protected]('name,value', itertools.product( + data.TYPE_NAMES, + data.BAD_VERSIONS +)) +def test_type_bad_version(parser, name, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +{{ name }}_types: + MyType: + version: {{ value }} +""", dict(name=name, value=value)).assert_failure()
