You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by em...@apache.org on 2017/09/19 21:29:38 UTC
[1/2] incubator-ariatosca git commit: Consolidate tests using Jinja
templates
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-1-parser-test-suite a136c92f9 -> 1d8ac549b
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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 307b40c..65f708c 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
@@ -14,13 +14,6 @@
# 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_interface_type.py,
- test_node_type_relationship_interfaces.py.
-"""
-
import itertools
import pytest
@@ -28,413 +21,323 @@ import pytest
from ... import data
-TYPE_NAMES = ('node', 'relationship', 'group')
+MAIN_MACROS = """
+{% macro additions() %}
+{%- endmacro %}
+{% macro interfaces() %}
+ interfaces: {{ caller()|indent(6) }}
+{%- endmacro %}
+"""
+
+RELATIONSHIP_MACROS = """
+{% macro additions() %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+{%- endmacro %}
+{% macro interfaces() %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces: {{ caller()|indent(14) }}
+{%- endmacro %}
+"""
+
+MACROS = {
+ 'main': MAIN_MACROS,
+ 'relationship': RELATIONSHIP_MACROS
+}
+
+INTERFACE_SECTIONS = (
+ ('main', 'node'),
+ ('main', 'group'),
+ ('main', 'relationship'),
+ ('relationship', 'node')
+)
# Syntax
-@pytest.mark.parametrize('name,value', itertools.product(
- TYPE_NAMES,
- data.NOT_A_DICT
-))
-def test_type_interface_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
+@pytest.mark.parametrize(
+ 'macros,name,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(INTERFACE_SECTIONS, data.NOT_A_DICT))
+)
+def test_type_interface_wrong_yaml_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface: {{ value }}
+{%- call interfaces() %}
+my_interface: {{ value }}
+{% endcall %}
""", dict(name=name, value=value)).assert_failure()
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_empty(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- interfaces:
- my_interface: {} # "type" is required
+{%- call interfaces() %}
+my_interface: {} # "type" is required
+{% endcall %}
""", dict(name=name)).assert_failure()
-@pytest.mark.parametrize('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()
-
-
# Type
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_type_override(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType1: {}
MyType2:
derived_from: MyType1
{{ name }}_types:
MyType1:
- interfaces:
- my_interface:
- type: MyType1
+{%- call interfaces() %}
+my_interface:
+ type: MyType1
+{% endcall %}
MyType2:
derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType2
+{%- call interfaces() %}
+my_interface:
+ type: MyType2
+{% endcall %}
""", dict(name=name)).assert_success()
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_type_override_bad(parser, name):
- parser.parse_literal("""
+@pytest.mark.skip(reason='fix for node.relationship')
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_type_override_bad(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType1: {}
MyType2:
derived_from: MyType1
{{ name }}_types:
MyType1:
- interfaces:
- my_interface:
- type: MyType2
+{%- call interfaces() %}
+my_interface:
+ type: MyType2
+{% endcall %}
MyType2:
derived_from: MyType1
- interfaces:
- my_interface:
- type: MyType1
+{%- call interfaces() %}
+my_interface:
+ type: MyType1
+{% endcall %}
""", dict(name=name)).assert_failure()
-# Interface inputs
-
-@pytest.mark.parametrize('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()
-
+# Operations
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_inputs_type_override_same(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_operation_empty(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
- MyType:
- inputs:
- my_input:
- type: string
+ MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: string
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation: {}
+{% endcall %}
""", dict(name=name)).assert_success()
-@pytest.mark.parametrize('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()
-
+# Operation description
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('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
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_empty(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize(
+ 'macros,name,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(INTERFACE_SECTIONS, data.NOT_A_DICT))
+)
+def test_type_interface_operation_description_wrong_yaml_type(parser, macros, name, value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation: {}
-""", dict(name=name)).assert_success()
-
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ description: {{ value }}
+{% endcall %}
+""", dict(name=name)).assert_failure()
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_fields(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_operation_description(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- description: a description
- implementation: {}
- inputs: {}
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ description: a description
+{% endcall %}
""", dict(name=name)).assert_success()
# Operation implementation
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_short_form(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_operation_implementation_short_form(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation: an implementation
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ implementation: an implementation
+{% endcall %}
""", dict(name=name)).assert_success()
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_implementation_long_form(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_operation_implementation_long_form(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - a dependency
- - another dependency
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - a dependency
+ - another dependency
+{% endcall %}
""", dict(name=name)).assert_success()
-@pytest.mark.parametrize('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("""
+@pytest.mark.parametrize(
+ 'macros,name,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(INTERFACE_SECTIONS, data.NOT_A_STRING))
+)
+def test_type_interface_operation_implementation_primary_wrong_yaml_type(parser, macros, name,
+ value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: {{ value }}
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: {{ value }}
+{% endcall %}
""", dict(name=name, value=value)).assert_failure()
-@pytest.mark.parametrize('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("""
+@pytest.mark.parametrize(
+ 'macros,name,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(INTERFACE_SECTIONS, data.NOT_A_LIST))
+)
+def test_type_interface_operation_implementation_dependencies_wrong_yaml_type(parser, macros, name,
+ value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - {{ value }}
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies: {{ value }}
+{% endcall %}
""", dict(name=name, value=value)).assert_failure()
-# Operation inputs
-
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_operation_inputs_add(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize(
+ 'macros,name,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(INTERFACE_SECTIONS, data.NOT_A_STRING))
+)
+def test_type_interface_operation_implementation_dependencies_element_wrong_yaml_type(parser,
+ macros,
+ name,
+ value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
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()
-
-
-@pytest.mark.parametrize('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()
-
-
-@pytest.mark.parametrize('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()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('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
+ MyType: {}
{{ name }}_types:
MyType:
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: MyType1
-""", dict(name=name)).assert_failure()
+{%- call interfaces() %}
+my_interface:
+ type: MyType
+ my_operation:
+ implementation:
+ primary: an implementation
+ dependencies:
+ - {{ value }}
+{% endcall %}
+""", dict(name=name, value=value)).assert_failure()
# Unicode
-@pytest.mark.parametrize('name', TYPE_NAMES)
-def test_type_interface_unicode(parser, name):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name', INTERFACE_SECTIONS)
+def test_type_interface_unicode(parser, macros, name):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
interface_types:
類型: {}
{{ name }}_types:
類型:
- interfaces:
- 接口:
- type: 類型
- 手術:
- implementation: 履行
+{%- call interfaces() %}
+接口:
+ type: 類型
+ 手術:
+ implementation: 履行
+{% endcall %}
""", dict(name=name)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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 aa2eda6..2fd67b0 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
@@ -21,161 +21,430 @@ import pytest
from ... import data
+MAIN_MACROS = """
+{% macro additions() %}
+{%- endmacro %}
+{% macro parameters() %}
+ {{ parameter_section }}: {{ caller()|indent(6) }}
+{%- endmacro %}
+"""
+
+NESTED_MACROS = """
+{% macro additions() %}
+{%- endmacro %}
+{% macro parameters() %}
+ nested:
+ {{ parameter_section }}: {{ caller()|indent(8) }}
+{%- endmacro %}
+"""
+
+INTERFACE_MACROS = """
+{% macro additions() %}
+interface_types:
+ MyType: {}
+{%- endmacro %}
+{% macro parameters() %}
+ interfaces:
+ my_interface:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(10) }}
+{%- endmacro %}
+"""
+
+OPERATION_MACROS = """
+{% macro additions() %}
+interface_types:
+ MyType: {}
+{%- endmacro %}
+{% macro parameters() %}
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ {{ parameter_section }}: {{ caller()|indent(12) }}
+{%- endmacro %}
+"""
+
+RELATIONSHIP_INTERFACE_MACROS = """
+{% macro additions() %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+{%- endmacro %}
+{% macro parameters() %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(20) }}
+{%- endmacro %}
+"""
+
+RELATIONSHIP_OPERATION_MACROS = """
+{% macro additions() %}
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+interface_types:
+ MyType: {}
+{%- endmacro %}
+{% macro parameters() %}
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship:
+ type: MyType
+ interfaces:
+ my_interface:
+ type: MyType
+ my_operation:
+ {{ parameter_section }}: {{ caller()|indent(22) }}
+{%- endmacro %}
+"""
+
+CAPABILITY_MACROS = """
+{% macro additions() %}
+capability_types:
+ MyType: {}
+{%- endmacro %}
+{% macro parameters() %}
+ capabilities:
+ my_capability:
+ type: MyType
+ {{ parameter_section }}: {{ caller()|indent(10) }}
+{%- endmacro %}
+"""
+
+MACROS = {
+ 'main': MAIN_MACROS,
+ 'nested': NESTED_MACROS,
+ 'interface': INTERFACE_MACROS,
+ 'operation': OPERATION_MACROS,
+ 'relationship-interface': RELATIONSHIP_INTERFACE_MACROS,
+ 'relationship-operation': RELATIONSHIP_OPERATION_MACROS,
+ 'capability': CAPABILITY_MACROS
+}
+
+PARAMETER_SECTIONS = (
+ ('main', 'node', 'properties'),
+ ('main', 'node', 'attributes'),
+ ('main', 'group', 'properties'),
+ ('main', 'relationship', 'properties'),
+ ('main', 'relationship', 'attributes'),
+ ('main', 'capability', 'properties'),
+ ('main', 'capability', 'attributes'),
+ ('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'),
+ ('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')
+)
+
+
# Syntax
@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(data.PARAMETER_SECTIONS, data.NOT_A_DICT))
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PARAMETER_SECTIONS, data.NOT_A_DICT))
)
-def test_type_parameter_section_wrong_yaml_type(parser, name, parameter_section, value):
- parser.parse_literal("""
+def test_type_parameter_section_wrong_yaml_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}: {{ value }}
+{%- call parameters() -%}
+{{ value }}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_section_empty(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_section_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}: {}
+{%- call parameters() -%}
+{}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(data.PARAMETER_SECTIONS, data.NOT_A_DICT))
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PARAMETER_SECTIONS, data.NOT_A_DICT))
)
-def test_type_parameter_wrong_yaml_type(parser, name, parameter_section, value):
- parser.parse_literal("""
+def test_type_parameter_wrong_yaml_type(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter: {{ value }}
+{%- call parameters() %}
+my_parameter: {{ value }}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_empty(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter: {} # type is required
+{%- call parameters() %}
+my_parameter: {} # type is required
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_unsupported_field(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_unsupported_field(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- unsupported_field: {}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ unsupported: {}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
-# Fields
+# Description
+
+@pytest.mark.parametrize(
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PARAMETER_SECTIONS, data.NOT_A_STRING))
+)
+def test_type_parameter_description_wrong_yaml_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
+ description: {{ value }}
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
+
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_fields(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_description(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- description: a description
- default: a value
- status: supported
+{%- call parameters() %}
+my_parameter:
+ type: string
+ description: a description
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+# Default
+
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_default(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
+ default: a string
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_default_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: integer
+ default: a string
+{% endcall %}
+""", dict(name=name, parameter_section=parameter_section)).assert_failure()
+
+
+# Required
+
+@pytest.mark.parametrize(
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PROPERTY_SECTIONS, data.NOT_A_BOOL))
+)
+def test_type_parameter_required_wrong_yaml_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()
+
+@pytest.mark.parametrize('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(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(data.PARAMETER_SECTIONS, data.STATUSES))
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PARAMETER_SECTIONS, data.STATUSES))
)
-def test_type_parameter_status(parser, name, parameter_section, value):
- parser.parse_literal("""
+def test_type_parameter_status(parser, macros, name, parameter_section, value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: {{ value }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ status: {{ value }}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, value=value)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_status_bad(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_status_bad(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: not a status
+{%- call parameters() %}
+my_parameter:
+ type: string
+ status: not a status
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
# Constraints
@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(data.PARAMETER_WITH_CONSTRAINTS_SECTIONS, data.NOT_A_LIST))
+ 'macros,name,parameter_section,value',
+ ((s[0], s[1], s[2], v)
+ for s, v in itertools.product(PROPERTY_SECTIONS, data.NOT_A_LIST))
)
-def test_type_parameter_constraints_wrong_yaml_type(parser, name, parameter_section, value):
- parser.parse_literal("""
+def test_type_parameter_constraints_wrong_yaml_type(parser, macros, name, parameter_section,
+ value):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints: {{ value }}
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints: {{ value }}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, value=value)).assert_failure()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
-def test_type_parameter_constraints_empty(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PROPERTY_SECTIONS)
+def test_type_parameter_constraints_empty(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints: []
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints: []
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_VALUE))
)
-def test_type_parameter_constraints_with_value(parser, name, parameter_section, constraint):
- parser.parse_literal("""
+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:
@@ -185,24 +454,27 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType
- constraints:
- - {{ constraint }}: {my_field: a string}
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType
+ constraints:
+ - {{ constraint }}: {my_field: a string}
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_VALUE_LIST))
)
-def test_type_parameter_constraints_with_value_list(parser, name, parameter_section, constraint):
- parser.parse_literal("""
+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:
@@ -212,27 +484,30 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType
- constraints:
- - {{ constraint }}:
- - {my_field: string one}
- - {my_field: string two}
- - {my_field: string three}
+{%- 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()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_VALUE_RANGE))
)
-def test_type_parameter_constraints_with_value_range(parser, name, parameter_section, constraint):
- parser.parse_literal("""
+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:
@@ -242,27 +517,29 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType
- constraints:
- - {{ constraint }}:
- - {my_field: string a}
- - {my_field: string b}
+{%- 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()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_VALUE_RANGE))
)
-def test_type_parameter_constraints_with_value_range_too_many(parser, name, parameter_section,
- constraint):
- parser.parse_literal("""
+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:
@@ -272,28 +549,30 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType
- constraints:
- - {{ constraint }}:
- - {my_field: string a}
- - {my_field: string b}
- - {my_field: string c}
+{%- 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()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_VALUE_RANGE))
)
-def test_type_parameter_constraints_with_value_range_invalid(parser, name, parameter_section,
- constraint):
- parser.parse_literal("""
+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:
@@ -303,125 +582,144 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType
- constraints:
- - {{ constraint }}:
- - {my_field: string b}
- - {my_field: string a}
+{%- 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()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
-def test_type_parameter_constraints_pattern(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('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:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints:
- - pattern: ^pattern$
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - pattern: ^pattern$
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
-def test_type_parameter_constraints_pattern_bad(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('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:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints:
- - pattern: (
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - pattern: (
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_NON_NEGATIVE_INT))
)
-def test_type_parameter_constraints_with_integer(parser, name, parameter_section, constraint):
- parser.parse_literal("""
+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:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints:
- - {{ constraint }}: 1
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: 1
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_success()
@pytest.mark.parametrize(
- 'name,parameter_section,constraint',
- ((s[0], s[1], v)
+ 'macros,name,parameter_section,constraint',
+ ((s[0], s[1], s[2], v)
for s, v in itertools.product(
- data.PARAMETER_WITH_CONSTRAINTS_SECTIONS,
+ PROPERTY_SECTIONS,
data.CONSTRAINTS_WITH_NON_NEGATIVE_INT))
)
-def test_type_parameter_constraints_with_integer_bad(parser, name, parameter_section, constraint):
- parser.parse_literal("""
+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:
- {{ parameter_section }}:
- my_parameter:
- type: string
- constraints:
- - {{ constraint }}: -1
+{%- call parameters() %}
+my_parameter:
+ type: string
+ constraints:
+ - {{ constraint }}: -1
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section, constraint=constraint)).assert_failure()
# Overriding
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_add(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_add(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType1:
- {{ parameter_section }}:
- my_parameter1:
- type: string
+{%- call parameters() %}
+my_parameter1:
+ type: string
+{% endcall %}
MyType2:
derived_from: MyType1
- {{ parameter_section }}:
- my_parameter2:
- type: string
+{%- call parameters() %}
+my_parameter2:
+ type: string
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_add_default(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_add_default(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: string
+{%- call parameters() %}
+my_parameter:
+ type: string
+{% endcall %}
MyType2:
derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: string
- default: my value
+{%- call parameters() %}
+my_parameter:
+ type: string
+ default: my value
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_type_override(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.skip(reason='fix for node.capability and node.relationship')
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_type_override(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
data_types:
MyDataType1: {}
MyDataType2:
@@ -430,21 +728,25 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType1
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType1
+{% endcall %}
MyType2:
derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType2
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType2
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_type_override_bad(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.skip(reason='fix for node.capability and node.relationship')
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+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
+{{- additions() }}
data_types:
MyDataType1: {}
MyDataType2:
@@ -453,43 +755,49 @@ data_types:
{{ name }}_types:
{%- endif %}
MyType1:
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType2
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType2
+{% endcall %}
MyType2:
derived_from: MyType1
- {{ parameter_section }}:
- my_parameter:
- type: MyDataType1
+{%- call parameters() %}
+my_parameter:
+ type: MyDataType1
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_failure()
# Unicode
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_SECTIONS)
-def test_type_parameter_unicode(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('macros,name,parameter_section', PARAMETER_SECTIONS)
+def test_type_parameter_unicode(parser, macros, name, parameter_section):
+ parser.parse_literal(MACROS[macros] + """
tosca_definitions_version: tosca_simple_yaml_1_0
+{{- additions() }}
{{ name }}_types:
MyType:
- {{ parameter_section }}:
- 參數:
- type: string
- description: 描述
- default: 值
- status: supported
+{%- call parameters() %}
+參數:
+ type: string
+ description: 描述
+ default: 值
+ status: supported
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
-@pytest.mark.parametrize('name,parameter_section', data.PARAMETER_WITH_CONSTRAINTS_SECTIONS)
-def test_type_parameter_constraints_pattern_unicode(parser, name, parameter_section):
- parser.parse_literal("""
+@pytest.mark.parametrize('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:
類型:
- {{ parameter_section }}:
- 參數:
- type: string
- constraints:
- - pattern: ^模式$
+{%- call parameters() %}
+參數:
+ type: string
+ constraints:
+ - pattern: ^模式$
+{% endcall %}
""", dict(name=name, parameter_section=parameter_section)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
index d46a322..80a74ef 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/common/test_types.py
@@ -54,38 +54,64 @@ tosca_definitions_version: tosca_simple_yaml_1_0
""", dict(name=name)).assert_success()
+# Description
+
@pytest.mark.parametrize('name,value', itertools.product(
data.TYPE_NAMES,
data.NOT_A_STRING
))
-def test_type_derived_from_wrong_yaml_type(parser, name, value):
+def test_type_description_wrong_yaml_type(parser, name, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
{{ name }}_types:
MyType:
- derived_from: {{ value }}
+ description: {{ value }}
""", dict(name=name, value=value)).assert_failure()
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_description(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ description: a description
+""", dict(name=name)).assert_success()
+
+
# Derived from
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_unknown(parser, name):
+@pytest.mark.parametrize('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: UnknownType
-""", dict(name=name)).assert_failure()
+ derived_from: {{ value }}
+""", dict(name=name, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TYPE_NAMES)
+def test_type_derived_from(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType1: {}
+ MyType2:
+ derived_from: MyType1
+""", dict(name=name)).assert_success()
@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_derived_from_null(parser, name):
+def test_type_derived_from_unknown(parser, name):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
{{ name }}_types:
MyType:
- derived_from: null
+ derived_from: UnknownType
""", dict(name=name)).assert_failure()
@@ -113,37 +139,26 @@ tosca_definitions_version: tosca_simple_yaml_1_0
""", dict(name=name)).assert_failure()
-@pytest.mark.parametrize('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:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-""", dict(name=name)).assert_success()
-
-
-# Common fields
+# Version
-@pytest.mark.parametrize('name', data.TYPE_NAMES)
-def test_type_fields(parser, name):
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TYPE_NAMES,
+ data.GOOD_VERSIONS
+))
+def test_type_version(parser, name, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
{{ name }}_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
- version: 1.0.0
- description: a description
-""", dict(name=name)).assert_success()
+ MyType:
+ version: {{ value }}
+""", dict(name=name, value=value)).assert_success()
@pytest.mark.parametrize('name,value', itertools.product(
data.TYPE_NAMES,
data.BAD_VERSIONS
))
-def test_type_bad_version(parser, name, value):
+def test_type_version_bad(parser, name, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
{{ name }}_types:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
index d3de459..5651fe6 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_capabilities.py
@@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import itertools
-
import pytest
from ... import data
@@ -57,7 +55,24 @@ node_types:
""").assert_failure()
-def test_node_type_capability_fields(parser):
+# Description
+
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_capability_description_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ description: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_capability_description(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -68,34 +83,31 @@ node_types:
my_capability:
type: MyType
description: a description
- properties: {}
- attributes: {}
- valid_source_types: []
- occurrences: [ 0, UNBOUNDED ]
""").assert_success()
# Type
-def test_node_type_capability_type_unknown(parser):
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_capability_type_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
node_types:
MyType:
capabilities:
my_capability:
- type: UnknownType
-""").assert_failure()
+ type: {{ value }}
+""", dict(value=value)).assert_failure()
-def test_node_type_capability_type_null(parser):
+def test_node_type_capability_type_unknown(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
node_types:
MyType:
capabilities:
my_capability:
- type: null
+ type: UnknownType
""").assert_failure()
@@ -139,157 +151,6 @@ node_types:
""").assert_failure()
-# Parameters
-
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_fields(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: string
- description: a description
- default: a value
- status: supported
-""", dict(parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('parameter_section,value', itertools.product(
- data.PARAMETER_SECTION_NAMES,
- data.STATUSES
-))
-def test_node_type_capability_parameter_status(parser, parameter_section, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: {{ value }}
-""", dict(parameter_section=parameter_section, value=value)).assert_success()
-
-
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_status_bad(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: string
- status: not a status
-""", dict(parameter_section=parameter_section)).assert_failure()
-
-
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_add(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType:
- {{ parameter_section }}:
- my_parameter1:
- type: string
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter2:
- type: string
-""", dict(parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_add_default(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: string
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: string
- default: my value
-""", dict(parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_type_override(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-capability_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyType1
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: MyType2
-""", dict(parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('parameter_section', data.PARAMETER_SECTION_NAMES)
-def test_node_type_capability_parameter_type_override_bad(parser, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-capability_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: MyType2
-node_types:
- MyType:
- capabilities:
- my_capability:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- type: MyType1
-""", dict(parameter_section=parameter_section)).assert_failure()
-
-
# Valid source types
def test_node_type_capability_valid_source_types(parser):
@@ -351,8 +212,6 @@ node_types:
""").assert_success()
-
-
def test_node_type_capability_valid_source_types_unknown(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -369,7 +228,7 @@ node_types:
# Occurrences
-@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+@pytest.mark.parametrize('value', data.OCCURRENCES)
def test_node_type_capability_occurrences(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -381,6 +240,21 @@ node_types:
my_capability:
type: MyType
occurrences: {{ value }}
+""", dict(value=value)).assert_success()
+
+
+@pytest.mark.parametrize('value', data.BAD_OCCURRENCES)
+def test_node_type_capability_occurrences_bad(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ capabilities:
+ my_capability:
+ type: MyType
+ occurrences: {{ value }}
""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
index c369328..ee34a3a 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_relationship_interfaces.py
@@ -15,128 +15,15 @@
# limitations under the License.
"""
-Developer note: make sure that these tests mirror those in:
- test_interface_type.py,
- test_type_interfaces.py.
+These tests are in addition to those in common/test_type_interface.py.
"""
import pytest
-from ... import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('value', data.NOT_A_DICT)
-def test_node_type_relationship_interface_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
-def test_node_type_relationship_interface_unsupported_field(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- unsupported: {}
-""").assert_failure()
-
-
-def test_node_type_relationship_interface_empty(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface: {} # "type" is required
-""").assert_failure()
-
-
-def test_node_type_relationship_interface_fields(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- inputs: {}
- my_operation1: {}
- my_operation2: {}
-""").assert_success()
-
# Type
-def test_node_type_relationship_interface_type_override1(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType1
-interface_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType2
-""").assert_success()
-
-
-def test_node_type_relationship_interface_type_override2(parser):
+def test_node_type_relationship_interface_type_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -171,35 +58,7 @@ node_types:
@pytest.mark.skip(reason='fix')
-def test_node_type_relationship_interface_type_override1_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType:
- interfaces:
- my_interface:
- type: MyType2
-interface_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType1
-""").assert_failure()
-
-
-@pytest.mark.skip(reason='fix')
-def test_node_type_relationship_interface_type_override2_bad(parser):
+def test_node_type_relationship_interface_type_override_bad(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -231,438 +90,3 @@ node_types:
my_interface:
type: MyType1
""").assert_failure()
-
-
-# Interface inputs
-
-def test_node_type_relationship_interface_inputs_add(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input2:
- type: string
-""").assert_success()
-
-
-def test_node_type_relationship_interface_inputs_type_override_same(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType:
- inputs:
- my_input:
- type: string
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: string
-""").assert_success()
-
-
-def test_node_type_relationship_interface_inputs_type_override_derived(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType1
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: MyType2
-""").assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-def test_node_type_relationship_interface_inputs_type_override_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType2
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- inputs:
- my_input:
- type: MyType1
-""").assert_failure()
-
-
-# Operations
-
-def test_node_type_relationship_interface_operation_empty(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation: {}
-""").assert_success()
-
-
-def test_node_type_relationship_interface_operation_fields(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- description: a description
- implementation: {}
- inputs: {}
-""").assert_success()
-
-
-# Operation implementation
-
-def test_node_type_relationship_interface_operation_implementation_short_form(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation: an implementation
-""").assert_success()
-
-
-def test_node_type_relationship_interface_operation_implementation_long_form(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - a dependency
- - another dependency
-""").assert_success()
-
-
-@pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_node_type_relationship_interface_operation_implementation_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: {{ value }}
-""", dict(value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('value', data.NOT_A_STRING)
-def test_node_type_relationship_interface_operation_dependencies_wrong_yaml_type(parser, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType: {}
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- implementation:
- primary: an implementation
- dependencies:
- - {{ value }}
-""", dict(value=value)).assert_failure()
-
-
-# Operation inputs
-
-def test_node_type_relationship_interface_operation_inputs_add(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType:
- inputs:
- my_input1:
- type: string
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input2:
- type: string
-""").assert_success()
-
-
-def test_node_type_relationship_interface_operation_inputs_override_same_type(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-interface_types:
- MyType:
- inputs:
- my_input:
- type: string
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: string
-""").assert_success()
-
-
-def test_node_type_relationship_interface_operation_inputs_override_derived_type(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType1
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: MyType2
-""").assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-def test_node_type_relationship_interface_operation_inputs_override_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType:
- inputs:
- my_input:
- type: MyType2
-node_types:
- MyType:
- requirements:
- - my_requirement:
- capability: MyType
- relationship:
- type: MyType
- interfaces:
- my_interface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: MyType1
-""").assert_failure()
-
-
-# Unicode
-
-def test_node_type_relationship_interface_unicode(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- 類型: {}
-relationship_types:
- 類型: {}
-interface_types:
- 類型: {}
-node_types:
- 類型:
- requirements:
- - 需求:
- capability: 類型
- relationship:
- type: 類型
- interfaces:
- 接口:
- type: 類型
- 手術:
- implementation: 履行
-""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
index 2f3e6a5..f2a2fa4 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/node_types/test_node_type_requirements.py
@@ -32,6 +32,20 @@ node_types:
""", dict(value=value)).assert_failure()
+def test_node_type_requirement_unsupported_field(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ unsupported: {}
+""").assert_failure()
+
+
def test_node_type_requirement_empty(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -42,28 +56,21 @@ node_types:
""").assert_failure()
-def test_node_type_requirement_fields(parser):
+# Capability
+
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_node_type_requirement_capability_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
-capability_types:
- MyType: {}
-relationship_types:
- MyType: {}
node_types:
MyType:
requirements:
- my_requirement:
- capability: MyType
- node: MyType
- relationship:
- type: MyType
- occurrences: [ 0, UNBOUNDED ]
-""").assert_success()
-
+ capability: {{ value }}
+""", dict(value=value)).assert_failure()
-# Capability
-def test_node_type_requirement_capability_short_form(parser):
+def test_node_type_requirement_capability_unsupported_field(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -71,33 +78,36 @@ capability_types:
node_types:
MyType:
requirements:
- - my_requirement: MyType
-""").assert_success()
+ - my_requirement:
+ capability:
+ unsupported: {}
+""").assert_failure()
-def test_node_type_requirement_capability_unknown(parser):
+def test_node_type_requirement_capability_short_form(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
node_types:
MyType:
requirements:
- - my_requirement:
- capability: UnknownType
-""").assert_failure()
+ - my_requirement: MyType
+""").assert_success()
-def test_node_type_requirement_capability_null(parser):
+def test_node_type_requirement_capability_type_unknown(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
node_types:
MyType:
requirements:
- my_requirement:
- capability: null
+ capability: UnknownType
""").assert_failure()
-def test_node_type_requirement_capability_override(parser):
+def test_node_type_requirement_capability_type_override(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -118,7 +128,8 @@ node_types:
# Node
-def test_node_type_requirement_node_unknown(parser):
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_node_type_requirement_node_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -128,11 +139,11 @@ node_types:
requirements:
- my_requirement:
capability: MyType
- node: UnknownType
-""").assert_failure()
+ node: {{ value }}
+""", dict(value=value)).assert_failure()
-def test_node_type_requirement_node_null(parser):
+def test_node_type_requirement_node_unknown(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -142,7 +153,7 @@ node_types:
requirements:
- my_requirement:
capability: MyType
- node: null
+ node: UnknownType
""").assert_failure()
@@ -170,7 +181,22 @@ node_types:
# Relationship
-def test_node_type_requirement_relationship_type_unknown(parser):
+@pytest.mark.parametrize('value', data.NOT_A_DICT_OR_STRING)
+def test_node_type_requirement_relationship_type_wrong_yaml_type(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship: {{ value }}
+""", dict(value=value)).assert_failure()
+
+
+def test_node_type_requirement_relationship_unsupported_field(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -181,11 +207,27 @@ node_types:
- my_requirement:
capability: MyType
relationship:
- type: UnknownType
+ unsupported: {}
""").assert_failure()
-def test_node_type_requirement_relationship_type_null(parser):
+def test_node_type_requirement_relationship_short_form(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+relationship_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
+ relationship: MyType
+""").assert_success()
+
+
+def test_node_type_requirement_relationship_type_unknown(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
capability_types:
@@ -196,7 +238,7 @@ node_types:
- my_requirement:
capability: MyType
relationship:
- type: null
+ type: UnknownType
""").assert_failure()
@@ -227,7 +269,7 @@ node_types:
# Occurrences
-@pytest.mark.parametrize('value', data.NOT_OCCURRENCES)
+@pytest.mark.parametrize('value', data.OCCURRENCES)
def test_node_type_requirement_occurrences(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
@@ -237,7 +279,22 @@ node_types:
MyType:
requirements:
- my_requirement:
- type: MyType
+ capability: MyType
+ occurrences: {{ value }}
+""", dict(value=value)).assert_success()
+
+
+@pytest.mark.parametrize('value', data.BAD_OCCURRENCES)
+def test_node_type_requirement_occurrences_bad(parser, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+capability_types:
+ MyType: {}
+node_types:
+ MyType:
+ requirements:
+ - my_requirement:
+ capability: MyType
occurrences: {{ value }}
""", dict(value=value)).assert_failure()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
index 38669c0..c185fa0 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/types/test_interface_type.py
@@ -14,113 +14,42 @@
# 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_type_interfaces.py,
- test_node_type_relationship_interfaces.py.
-"""
-
import pytest
from .. import data
-# Interface inputs
-
-def test_interface_type_inputs_add(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- inputs:
- my_input1:
- type: string
- MyType2:
- derived_from: MyType1
- inputs:
- my_input2:
- type: string
-""").assert_success()
-
-
-def test_interface_type_inputs_type_override_same(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- inputs:
- my_input:
- type: string
- MyType2:
- derived_from: MyType1
- inputs:
- my_input:
- type: string
-""").assert_success()
-
+# Operations
-def test_interface_type_inputs_type_override_derived(parser):
+def test_interface_type_operation_empty(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
interface_types:
- MyType1:
- inputs:
- my_input:
- type: MyType1
- MyType2:
- derived_from: MyType1
- inputs:
- my_input:
- type: MyType2
+ MyType:
+ my_operation: {}
""").assert_success()
-@pytest.mark.skip(reason='fix')
-def test_interface_type_inputs_type_override_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType1:
- inputs:
- my_input:
- type: MyType2
- MyType2:
- derived_from: MyType1
- inputs:
- my_input:
- type: MyType1
-""").assert_failure()
+# Operation description
-
-# Operations
-
-def test_interface_type_operation_empty(parser):
+@pytest.mark.parametrize('value', data.NOT_A_STRING)
+def test_interface_type_operation_description_wrong_yaml_type(parser, value):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
interface_types:
MyType:
- my_operation: {}
-""").assert_success()
+ my_operation:
+ description: {{ value }}
+""", dict(value=value)).assert_failure()
-def test_interface_type_operation_fields(parser):
+def test_interface_type_operation_description(parser):
parser.parse_literal("""
tosca_definitions_version: tosca_simple_yaml_1_0
interface_types:
MyType:
my_operation:
description: a description
- implementation: {}
- inputs: {}
""").assert_success()
@@ -176,89 +105,6 @@ interface_types:
""", dict(value=value)).assert_failure()
-# Operation inputs
-
-def test_interface_type_operation_inputs_add(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- my_operation:
- inputs:
- my_input:
- type: string
- MyType2:
- derived_from: MyType1
- my_operation:
- inputs:
- my_input:
- type: string
-""").assert_success()
-
-
-def test_interface_type_operation_inputs_override_same_type(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType1:
- my_operation:
- inputs:
- my_input:
- type: string
- MyType2:
- derived_from: MyType1
- my_operation:
- inputs:
- my_input:
- type: string
-""").assert_success()
-
-
-def test_interface_type_operation_inputs_override_derived_type(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType1:
- my_operation:
- inputs:
- my_input:
- type: MyType1
- MyType2:
- derived_from: MyType1
- my_operation:
- inputs:
- my_input:
- type: MyType2
-""").assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-def test_interface_type_operation_inputs_override_bad(parser):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType1: {}
- MyType2:
- derived_from: MyType1
-interface_types:
- MyType1:
- my_operation:
- inputs:
- my_input:
- type: MyType2
- MyType2:
- derived_from: MyType1
- my_operation:
- inputs:
- my_input:
- type: MyType1
-""").assert_failure()
-
-
# Unicode
def test_interface_type_unicode(parser):
[2/2] incubator-ariatosca git commit: Consolidate tests using Jinja
templates
Posted by em...@apache.org.
Consolidate tests using Jinja templates
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/1d8ac549
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1d8ac549
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1d8ac549
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 1d8ac549b81f4d464169b37e54c61eb6c6626ba3
Parents: a136c92
Author: Tal Liron <ta...@gmail.com>
Authored: Tue Sep 19 16:29:25 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Tue Sep 19 16:29:25 2017 -0500
----------------------------------------------------------------------
.travis.yml | 6 +-
.../aria_extension_tosca/simple_v1_0/data.py | 35 +-
.../simple_v1_0/templates/common/__init__.py | 14 +
.../templates/common/test_template_interface.py | 598 +++++++++++++++
.../common/test_template_parameters.py | 440 +++++++++++
.../templates/common/test_templates.py | 92 +++
.../templates/test_template_interface.py | 598 ---------------
.../templates/test_template_parameters.py | 423 -----------
.../simple_v1_0/templates/test_templates.py | 102 ---
.../types/common/test_type_interfaces.py | 507 +++++--------
.../types/common/test_type_parameters.py | 752 +++++++++++++------
.../simple_v1_0/types/common/test_types.py | 73 +-
.../node_types/test_node_type_capabilities.py | 206 +----
.../test_node_type_relationship_interfaces.py | 582 +-------------
.../node_types/test_node_type_requirements.py | 125 ++-
.../simple_v1_0/types/test_interface_type.py | 176 +----
16 files changed, 2078 insertions(+), 2651 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index ce0d462..f046af8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ sudo: true
language: python
-# We need this only for "sudo: false"
+# We need this only if "sudo: false"
#addons:
# apt:
# sources:
@@ -55,9 +55,9 @@ env:
before_install:
# Ubuntu 14.04 (trusty) does not come with Python 2.6, so we will install it from Felix Krull's
- # PPA
+ # PPA (won't work if "sudo: false")
- if [[ $TOX_ENV = py26* ]]; then
- sudo add-apt-repository ppa:fkrull/deadsnakes -y;
+ sudo add-apt-repository --yes ppa:fkrull/deadsnakes;
sudo apt-get --quiet update;
sudo apt-get --yes install python2.6 python2.6-dev;
fi
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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 76205eb..7693132 100644
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/data.py
@@ -48,29 +48,6 @@ TEMPLATE_PARAMETER_SECTIONS = (
('relationship', 'attributes'),
('policy', 'properties')
)
-PARAMETER_SECTIONS = (
- ('artifact', 'properties'),
- ('data', 'properties'),
- ('capability', 'properties'),
- ('capability', 'attributes'),
- ('interface', 'inputs'),
- ('relationship', 'properties'),
- ('relationship', 'attributes'),
- ('node', 'properties'),
- ('node', 'attributes'),
- ('group', 'properties'),
- ('policy', 'properties')
-)
-PARAMETER_WITH_CONSTRAINTS_SECTIONS = (
- ('artifact', 'properties'),
- ('data', 'properties'),
- ('capability', 'properties'),
- ('interface', 'inputs'),
- ('relationship', 'properties'),
- ('node', 'properties'),
- ('group', 'properties'),
- ('policy', 'properties')
-)
CONSTRAINTS_WITH_VALUE = ('equal', 'greater_than', 'greater_or_equal', 'less_than', 'less_or_equal')
CONSTRAINTS_WITH_VALUE_LIST = ('valid_values',)
CONSTRAINTS_WITH_VALUE_RANGE = ('in_range',)
@@ -78,17 +55,19 @@ CONSTRAINTS_WITH_NON_NEGATIVE_INT = ('length', 'min_length', 'max_length')
# Values
-NOT_A_DICT = ('null', 'a string', '123', '0.123', '[]')
-NOT_A_DICT_OR_STRING = ('null', '123', '0.123', '[]')
-NOT_A_LIST = ('null', 'a string', '123', '0.123', '{}')
-NOT_A_STRING = ('null', '123', '0.123', '[]', '{}')
+NOT_A_DICT = ('null', 'true', 'a string', '123', '0.123', '[]')
+NOT_A_DICT_OR_STRING = ('null', 'true', '123', '0.123', '[]')
+NOT_A_LIST = ('null', 'true', 'a string', '123', '0.123', '{}')
+NOT_A_STRING = ('null', 'true', '123', '0.123', '[]', '{}')
+NOT_A_BOOL = ('null', '123', '0.123', '[]', '{}')
NOT_A_RANGE = NOT_A_LIST + (
'[]', '[ 1 ]', '[ 1, 2, 3 ]',
'[ 1, 1 ]', '[ 2, 1 ]',
'[ 1, a string ]', '[ a string, 1 ]',
'[ 1.5, 2 ]', '[ 1, 2.5 ]'
)
-NOT_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]',)
+OCCURRENCES = ('[ 0, 1 ]', '[ 10, UNBOUNDED ]')
+BAD_OCCURRENCES = NOT_A_RANGE + ('[ -1, 1 ]', '[ 0, unbounded ]')
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')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/__init__.py
@@ -0,0 +1,14 @@
+# 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.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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
new file mode 100644
index 0000000..ba55fc8
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_interface.py
@@ -0,0 +1,598 @@
+# -*- 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
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_DICT
+))
+def test_template_interfaces_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interfaces_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_DICT
+))
+def test_template_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:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_DICT
+))
+def test_template_interface_inputs_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ inputs: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_inputs_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ inputs: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_DICT_OR_STRING
+))
+def test_template_interface_operation_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_empty(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_DICT_OR_STRING
+))
+def test_template_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:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ implementation: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_implementation_unsupported_field(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ implementation:
+ unsupported: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_interface_operation_implementation_primary_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ implementation:
+ primary: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_interface_operation_implementation_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:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ implementation:
+ dependencies:
+ - {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+# Operations
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_from_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_from_interface_type(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType:
+ my_operation: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_missing(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+# Interface inputs
+
+@pytest.mark.parametrize(
+ 'name,type_name,value',
+ ((s, v[0], v[1])
+ for s, v in itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.PARAMETER_VALUES))
+)
+def test_template_interface_input_from_type(parser, name, type_name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ inputs:
+ my_input:
+ type: {{ type_name }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ inputs:
+ my_input: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
+ value=value)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,type_name,value',
+ ((s, v[0], v[1])
+ for s, v in itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.PARAMETER_VALUES))
+)
+def test_template_interface_input_from_interface_type(parser, name, type_name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+interface_types:
+ MyType:
+ inputs:
+ my_input:
+ type: {{ type_name }}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ inputs:
+ my_input: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
+ value=value)).assert_success()
+
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_input_missing(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ inputs:
+ my_input: a value
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+# Operation inputs
+
+@pytest.mark.parametrize(
+ 'name,type_name,value',
+ ((s, v[0], v[1])
+ for s, v in itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.PARAMETER_VALUES))
+)
+def test_template_interface_operation_input_from_type(parser, name, type_name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation:
+ inputs:
+ my_input:
+ type: {{ type_name }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ inputs:
+ my_input: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
+ value=value)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,type_name,value',
+ ((s, v[0], v[1])
+ for s, v in itertools.product(
+ data.TEMPLATE_WITH_INTERFACE_NAMES,
+ data.PARAMETER_VALUES))
+)
+def test_template_interface_operation_input_from_interface_type(parser, name, type_name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+interface_types:
+ MyType:
+ my_operation:
+ inputs:
+ my_input:
+ type: {{ type_name }}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ inputs:
+ my_input: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
+ value=value)).assert_success()
+
+
+@pytest.mark.skip(reason='fix')
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_operation_input_missing(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ MyType: {}
+{{ name }}_types:
+ MyType:
+ interfaces:
+ MyInterface:
+ type: MyType
+ my_operation: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ interfaces:
+ MyInterface:
+ my_operation:
+ inputs:
+ my_input: a value
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+# Unicode
+
+@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
+def test_template_interface_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+interface_types:
+ 類型: {}
+{{ name }}_types:
+ 類型:
+ interfaces:
+ 接口:
+ type: 類型
+ 手術:
+ inputs:
+ 輸入:
+ type: string
+topology_template:
+ {{ section }}:
+ 模板:
+ type: 類型
+ interfaces:
+ 接口:
+ 手術:
+ inputs:
+ 輸入: 值
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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
new file mode 100644
index 0000000..009c608
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_template_parameters.py
@@ -0,0 +1,440 @@
+# -*- 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
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,value',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.TEMPLATE_PARAMETER_SECTIONS,
+ data.NOT_A_DICT))
+)
+def test_template_parameter_section_wrong_yaml_type(parser, name, parameter_section, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}: {{ value }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section, value=value)).assert_failure()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_section_empty(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_unsupported_field(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType: {}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ unsupported
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_failure()
+
+
+# Type conformance
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_missing(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter1:
+ type: string
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter2: a value
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize('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: {{ type_name }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ type_name=type_name)).assert_failure()
+
+
+@pytest.mark.parametrize('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: {{ type_name }}
+ required: false
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ type_name=type_name)).assert_success()
+
+
+@pytest.mark.parametrize(
+ '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: {{ type_name }}
+ default: {{ value }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
+ value=value)).assert_success()
+
+
+# Entry schema
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,values',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.TEMPLATE_PARAMETER_SECTIONS,
+ data.ENTRY_SCHEMA_VALUES))
+)
+def test_template_parameter_map(parser, name, parameter_section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+ default: default value
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
+ values=values)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,values',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.TEMPLATE_PARAMETER_SECTIONS,
+ data.ENTRY_SCHEMA_VALUES_BAD))
+)
+def test_template_parameter_map_bad(parser, name, parameter_section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+ default: default value
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: map
+ entry_schema: {{ values[0] }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ key1: {{ values[1] }}
+ key2: {{ values[2] }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
+ values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_map_required_field(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: map
+ entry_schema: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ key: {my_field: a value}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_map_required_field_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: map
+ entry_schema: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ key: {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_failure()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,values',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.TEMPLATE_PARAMETER_SECTIONS,
+ data.ENTRY_SCHEMA_VALUES))
+)
+def test_template_parameter_list(parser, name, parameter_section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+ default: default value
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
+ values=values)).assert_success()
+
+
+@pytest.mark.parametrize(
+ 'name,parameter_section,values',
+ ((s[0], s[1], v)
+ for s, v in itertools.product(
+ data.TEMPLATE_PARAMETER_SECTIONS,
+ data.ENTRY_SCHEMA_VALUES_BAD))
+)
+def test_template_parameter_list_bad(parser, name, parameter_section, values):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+ default: default value
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: list
+ entry_schema: {{ values[0] }}
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ - {{ values[1] }}
+ - {{ values[2] }}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
+ values=values)).assert_failure()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_list_required_field(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: list
+ entry_schema: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ - {my_field: a value}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_success()
+
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_list_required_field_bad(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+{{ name }}_types:
+ MyType:
+ {{ parameter_section }}:
+ my_parameter:
+ type: list
+ entry_schema: MyType
+topology_template:
+ {{ section }}:
+ my_template:
+ type: MyType
+ {{ parameter_section }}:
+ my_parameter:
+ - {}
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_failure()
+
+
+# Unicode
+
+@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
+def test_template_parameter_unicode(parser, name, parameter_section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型:
+ {{ parameter_section }}:
+ 參數:
+ type: string
+topology_template:
+ {{ section }}:
+ 模板:
+ type: 類型
+ {{ parameter_section }}:
+ 參數: 值
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
+ parameter_section=parameter_section)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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
new file mode 100644
index 0000000..ef2ffcf
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/common/test_templates.py
@@ -0,0 +1,92 @@
+# -*- 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
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_unsupported_field(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ unsupported: {}
+""", dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+# Description
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_description_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ description: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+
+# Type
+
+@pytest.mark.parametrize('name,value', itertools.product(
+ data.TEMPLATE_NAMES,
+ data.NOT_A_STRING
+))
+def test_template_type_wrong_yaml_type(parser, name, value):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: {{ value }}
+""", dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_type_unknown(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+topology_template:
+ {{ section }}:
+ my_template:
+ type: UnknownType
+""", dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
+
+
+# Unicode
+
+@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
+def test_template_unicode(parser, name):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+{{ name }}_types:
+ 類型: {}
+topology_template:
+ {{ section }}:
+ 模板:
+ type: 類型
+ description: 描述
+""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_interface.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_interface.py b/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_interface.py
deleted file mode 100644
index 710d802..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_interface.py
+++ /dev/null
@@ -1,598 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_DICT
-))
-def test_template_interfaces_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interfaces_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_DICT
-))
-def test_template_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:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_DICT
-))
-def test_template_interface_inputs_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- inputs: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_inputs_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- inputs: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_DICT_OR_STRING
-))
-def test_template_interface_operation_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_empty(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_DICT_OR_STRING
-))
-def test_template_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:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- implementation: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_implementation_unsupported_field(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- implementation:
- unsupported: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_STRING
-))
-def test_template_interface_operation_implementation_primary_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- implementation:
- primary: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.NOT_A_STRING
-))
-def test_template_interface_operation_implementation_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:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- implementation:
- dependencies:
- - {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-# Operations
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_from_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_from_interface_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType:
- my_operation: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_missing(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-# Interface inputs
-
-@pytest.mark.parametrize(
- 'name,type_name,value',
- ((s, v[0], v[1])
- for s, v in itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.PARAMETER_VALUES))
-)
-def test_template_interface_input_from_type(parser, name, type_name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- inputs:
- my_input:
- type: {{ type_name }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- inputs:
- my_input: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
- value=value)).assert_success()
-
-
-@pytest.mark.parametrize(
- 'name,type_name,value',
- ((s, v[0], v[1])
- for s, v in itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.PARAMETER_VALUES))
-)
-def test_template_interface_input_from_interface_type(parser, name, type_name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-interface_types:
- MyType:
- inputs:
- my_input:
- type: {{ type_name }}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- inputs:
- my_input: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
- value=value)).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_input_missing(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- inputs:
- my_input: a value
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-# Operation inputs
-
-@pytest.mark.parametrize(
- 'name,type_name,value',
- ((s, v[0], v[1])
- for s, v in itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.PARAMETER_VALUES))
-)
-def test_template_interface_operation_input_from_type(parser, name, type_name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation:
- inputs:
- my_input:
- type: {{ type_name }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- inputs:
- my_input: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
- value=value)).assert_success()
-
-
-@pytest.mark.parametrize(
- 'name,type_name,value',
- ((s, v[0], v[1])
- for s, v in itertools.product(
- data.TEMPLATE_WITH_INTERFACE_NAMES,
- data.PARAMETER_VALUES))
-)
-def test_template_interface_operation_input_from_interface_type(parser, name, type_name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-interface_types:
- MyType:
- my_operation:
- inputs:
- my_input:
- type: {{ type_name }}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- inputs:
- my_input: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
- value=value)).assert_success()
-
-
-@pytest.mark.skip(reason='fix')
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_operation_input_missing(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- MyType: {}
-{{ name }}_types:
- MyType:
- interfaces:
- MyInterface:
- type: MyType
- my_operation: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- interfaces:
- MyInterface:
- my_operation:
- inputs:
- my_input: a value
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-# Unicode
-
-@pytest.mark.parametrize('name', data.TEMPLATE_WITH_INTERFACE_NAMES)
-def test_template_interface_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-interface_types:
- 類型: {}
-{{ name }}_types:
- 類型:
- interfaces:
- 接口:
- type: 類型
- 手術:
- inputs:
- 輸入:
- type: string
-topology_template:
- {{ section }}:
- 模板:
- type: 類型
- interfaces:
- 接口:
- 手術:
- inputs:
- 輸入: 值
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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
deleted file mode 100644
index 913000f..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_template_parameters.py
+++ /dev/null
@@ -1,423 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-# Syntax
-
-@pytest.mark.parametrize(
- 'name,parameter_section,value',
- ((s[0], s[1], v)
- for s, v in itertools.product(
- data.TEMPLATE_PARAMETER_SECTIONS,
- data.NOT_A_DICT))
-)
-def test_template_parameters_wrong_yaml_type(parser, name, parameter_section, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}: {{ value }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section, value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameters_empty(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_success()
-
-
-# Type conformance
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_missing(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter1:
- type: string
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter2: a value
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_failure()
-
-
-@pytest.mark.parametrize('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: {{ type_name }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- type_name=type_name)).assert_failure()
-
-
-@pytest.mark.parametrize('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: {{ type_name }}
- required: false
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- type_name=type_name)).assert_success()
-
-
-@pytest.mark.parametrize(
- '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: {{ type_name }}
- default: {{ value }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], type_name=type_name,
- value=value)).assert_success()
-
-
-# Entry schema
-
-@pytest.mark.parametrize(
- 'name,parameter_section,values',
- ((s[0], s[1], v)
- for s, v in itertools.product(
- data.TEMPLATE_PARAMETER_SECTIONS,
- data.ENTRY_SCHEMA_VALUES))
-)
-def test_template_parameter_map(parser, name, parameter_section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
- default: default value
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
- values=values)).assert_success()
-
-
-@pytest.mark.parametrize(
- 'name,parameter_section,values',
- ((s[0], s[1], v)
- for s, v in itertools.product(
- data.TEMPLATE_PARAMETER_SECTIONS,
- data.ENTRY_SCHEMA_VALUES_BAD))
-)
-def test_template_parameter_map_bad(parser, name, parameter_section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
- default: default value
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: map
- entry_schema: {{ values[0] }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- key1: {{ values[1] }}
- key2: {{ values[2] }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
- values=values)).assert_failure()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_map_required_field(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: map
- entry_schema: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- key: {my_field: a value}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_map_required_field_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: map
- entry_schema: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- key: {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_failure()
-
-
-@pytest.mark.parametrize(
- 'name,parameter_section,values',
- ((s[0], s[1], v)
- for s, v in itertools.product(
- data.TEMPLATE_PARAMETER_SECTIONS,
- data.ENTRY_SCHEMA_VALUES))
-)
-def test_template_parameter_list(parser, name, parameter_section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
- default: default value
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
- values=values)).assert_success()
-
-
-@pytest.mark.parametrize(
- 'name,parameter_section,values',
- ((s[0], s[1], v)
- for s, v in itertools.product(
- data.TEMPLATE_PARAMETER_SECTIONS,
- data.ENTRY_SCHEMA_VALUES_BAD))
-)
-def test_template_parameter_list_bad(parser, name, parameter_section, values):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
- default: default value
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: list
- entry_schema: {{ values[0] }}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- - {{ values[1] }}
- - {{ values[2] }}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name], parameter_section=parameter_section,
- values=values)).assert_failure()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_list_required_field(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: list
- entry_schema: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- - {my_field: a value}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_success()
-
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_list_required_field_bad(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-data_types:
- MyType:
- properties:
- my_field:
- type: string
-{{ name }}_types:
- MyType:
- {{ parameter_section }}:
- my_parameter:
- type: list
- entry_schema: MyType
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- {{ parameter_section }}:
- my_parameter:
- - {}
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_failure()
-
-
-# Unicode
-
-@pytest.mark.parametrize('name,parameter_section', data.TEMPLATE_PARAMETER_SECTIONS)
-def test_template_parameter_unicode(parser, name, parameter_section):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型:
- {{ parameter_section }}:
- 參數:
- type: string
-topology_template:
- {{ section }}:
- 模板:
- type: 類型
- {{ parameter_section }}:
- 參數: 值
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name],
- parameter_section=parameter_section)).assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1d8ac549/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
deleted file mode 100644
index 1878990..0000000
--- a/tests/extensions/aria_extension_tosca/simple_v1_0/templates/test_templates.py
+++ /dev/null
@@ -1,102 +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 itertools
-
-import pytest
-
-from .. import data
-
-
-# Syntax
-
-@pytest.mark.parametrize('name,value', itertools.product(
- data.TEMPLATE_NAMES,
- data.NOT_A_STRING
-))
-def test_template_type_wrong_yaml_type(parser, name, value):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: {{ value }}
-""", dict(section=data.TEMPLATE_NAME_SECTIONS[name], value=value)).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_unsupported_field(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- unsupported: {}
-""", dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-# Common fields
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_fields(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- MyType: {}
-topology_template:
- {{ section }}:
- my_template:
- type: MyType
- description: a description
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_unknown_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: UnknownType
-""", dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_of_null_type(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-topology_template:
- {{ section }}:
- my_template:
- type: null
-""", dict(section=data.TEMPLATE_NAME_SECTIONS[name])).assert_failure()
-
-
-# Unicode
-
-@pytest.mark.parametrize('name', data.TEMPLATE_NAMES)
-def test_template_unicode(parser, name):
- parser.parse_literal("""
-tosca_definitions_version: tosca_simple_yaml_1_0
-{{ name }}_types:
- 類型: {}
-topology_template:
- {{ section }}:
- 模板:
- type: 類型
- description: 描述
-""", dict(name=name, section=data.TEMPLATE_NAME_SECTIONS[name])).assert_success()