More template 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/4e876578 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/4e876578 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/4e876578 Branch: refs/heads/ARIA-1-parser-test-suite Commit: 4e876578b6e7993400971b369ae17b29c09b6f14 Parents: 195000a Author: Tal Liron <[email protected]> Authored: Fri Sep 8 13:57:32 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Mon Sep 11 13:58:58 2017 -0500 ---------------------------------------------------------------------- .../aria_extension_tosca/simple_v1_0/data.py | 7 +++ .../templates/test_template_parameters.py | 56 +++++++++++++++----- .../simple_v1_0/templates/test_templates.py | 15 ------ .../templates/test_topology_template.py | 54 +++++++++++++++++++ tox.ini | 5 -- 5 files changed, 104 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e876578/tests/extensions/aria_extension_tosca/simple_v1_0/data.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py index 7310ed9..1859037 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py @@ -86,6 +86,13 @@ NOT_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]',) GOOD_VERSIONS = ("'6.1'", '2.0.1', '3.1.0.beta', "'1.0.0.alpha-10'") BAD_VERSIONS = ('a_string', '1.2.3.4.5', '1.2.beta', '1.0.0.alpha-x') STATUSES = ('supported', 'unsupported', 'experimental', 'deprecated') +PARAMETER_TYPE_NAMES = PRIMITIVE_TYPE_NAMES + ('MyType',) +PARAMETER_VALUES = ( + ('string', 'a string'), + ('integer', '1'), + ('float', '1.1'), + ('MyType', '{my_field: a string}') +) ENTRY_SCHEMA_VALUES = ( ('string', 'a string', 'another string'), ('integer', '1', '2'), http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e876578/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py index 48087d0..a0d536f 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py @@ -24,54 +24,84 @@ from .. import data # Required properties @pytest.mark.skip(reason='fixed in ARIA-351') [email protected]('name', data.TEMPLATE_NAMES) -def test_template_property_required(parser, name): [email protected]('name,type_name', itertools.product( + data.TEMPLATE_NAMES, + data.PARAMETER_TYPE_NAMES +)) +def test_template_property_required(parser, name, type_name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType: + properties: + my_field: + type: string {{ name }}_types: MyType: properties: my_property: - type: string + type: {{ type_name }} topology_template: {{ section }}: my_template: type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure() +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], + type_name=type_name)).assert_failure() [email protected]('name', data.TEMPLATE_NAMES) -def test_template_property_not_required(parser, name): [email protected]('name,type_name', itertools.product( + data.TEMPLATE_NAMES, + data.PARAMETER_TYPE_NAMES +)) +def test_template_property_not_required(parser, name, type_name): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType: + properties: + my_field: + type: string {{ name }}_types: MyType: properties: my_property: - type: string + type: {{ type_name }} required: false topology_template: {{ section }}: my_template: type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], + type_name=type_name)).assert_success() [email protected]('name', data.TEMPLATE_NAMES) -def test_template_property_required_with_default(parser, name): [email protected]( + 'name,type_name,value', + ((s, v[0], v[1]) + for s, v in itertools.product( + data.TEMPLATE_NAMES, + data.PARAMETER_VALUES)) +) +def test_template_property_required_with_default(parser, name, type_name, value): parser.parse_literal(""" tosca_definitions_version: tosca_simple_yaml_1_0 +data_types: + MyType: + properties: + my_field: + type: string {{ name }}_types: MyType: properties: my_property: - type: string - default: a string + type: {{ type_name }} + default: {{ value }} topology_template: {{ section }}: my_template: type: MyType -""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success() +""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name, + value=value)).assert_success() # Entry schema http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e876578/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py index bcd232a..abbc6a4 100644 --- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py @@ -23,21 +23,6 @@ from .. import data # Syntax [email protected]('value', data.NOT_A_DICT) -def test_topology_template_wrong_yaml_type(parser, value): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -topology_template: {{ value }} -""", dict(value=value)).assert_failure() - - -def test_topology_template_empty(parser): - parser.parse_literal(""" -tosca_definitions_version: tosca_simple_yaml_1_0 -topology_template: {} -""").assert_success() - - @pytest.mark.parametrize('name,value', itertools.product( data.TEMPLATE_NAMES, data.NOT_A_DICT http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e876578/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py ---------------------------------------------------------------------- diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py new file mode 100644 index 0000000..dd3d443 --- /dev/null +++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_topology_template.py @@ -0,0 +1,54 @@ +# -*- 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 + + +# Syntax + [email protected]('value', data.NOT_A_DICT) +def test_topology_template_wrong_yaml_type(parser, value): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: {{ value }} +""", dict(value=value)).assert_failure() + + +def test_topology_template_empty(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +topology_template: {} +""").assert_success() + + +def test_topology_template_fields(parser): + parser.parse_literal(""" +tosca_definitions_version: tosca_simple_yaml_1_0 +node_types: + MyType: {} +topology_template: + description: a description + inputs: {} + node_templates: {} + relationship_templates: {} + groups: {} + policies: {} + outputs: {} + substitution_mappings: + node_type: MyType +""").assert_success() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4e876578/tox.ini ---------------------------------------------------------------------- diff --git a/tox.ini b/tox.ini index c061abe..62db516 100644 --- a/tox.ini +++ b/tox.ini @@ -13,13 +13,8 @@ [tox] envlist=py27,py26,py27e2e,py26e2e,py27extensions,py26extensions,py27ssh,py26ssh,pywin,pylint_code,pylint_tests,docs processes={env:PYTEST_PROCESSES:auto} -<<<<<<< HEAD py27={env:PY27:python2.7} py26={env:PY26:python2.6} -======= -py26={env:PY26:python2.6} -py27={env:PY27:python2.7} ->>>>>>> Use YAML C library [testenv] whitelist_externals=
