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/10/17 22:18:41 UTC
incubator-ariatosca git commit: More function tests
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-1-parser-test-suite 47cd3ba6b -> 40a93457f
More function tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/40a93457
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/40a93457
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/40a93457
Branch: refs/heads/ARIA-1-parser-test-suite
Commit: 40a93457f52612490aa574eb30519b16698b5954
Parents: 47cd3ba
Author: Tal Liron <ta...@gmail.com>
Authored: Tue Oct 17 17:18:28 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Tue Oct 17 17:18:28 2017 -0500
----------------------------------------------------------------------
aria/orchestrator/workflows/executor/process.py | 4 +-
.../simple_v1_0/modeling/functions.py | 14 +-
.../simple_v1_0/functions/__init__.py | 14 ++
.../functions/test_function_concat.py | 102 ++++++++
.../functions/test_function_get_artifact.py | 17 ++
.../functions/test_function_get_input.py | 94 +++++++
.../test_function_get_nodes_of_type.py | 17 ++
.../test_function_get_operation_output.py | 17 ++
.../functions/test_function_token.py | 119 +++++++++
.../test_functions_modelable_entity.py | 245 +++++++++++++++++++
10 files changed, 635 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index f28db8d..4143127 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -23,8 +23,8 @@ import os
import sys
# As part of the process executor implementation, subprocess are started with this module as their
-# entry point. We thus remove this module's directory from the python path if it happens to be
-# there
+# entry point. We thus remove this module's directory from the Python path if it happens to be
+# there.
from collections import namedtuple
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
index 26b756d..e1609cb 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py
@@ -95,6 +95,10 @@ class Token(Function):
argument[1])
self.substring_index = parse_int(context, presentation, 'token', 2,
'the 0-based index of the token to return', argument[2])
+ if self.substring_index < 0:
+ raise invalid_value('token', 2, 'a non-negative integer',
+ 'the 0-based index of the token to return', self.substring_index,
+ presentation._locator)
@property
def as_raw(self):
@@ -224,8 +228,7 @@ class GetProperty(Function):
properties = modelable_entity.properties
nested_property_name_or_index = self.nested_property_name_or_index
- evaluation = get_modelable_entity_parameter(modelable_entity, properties,
- nested_property_name_or_index)
+ evaluation = get_modelable_entity_parameter(properties, nested_property_name_or_index)
if evaluation is not None:
return evaluation
@@ -270,8 +273,7 @@ class GetAttribute(Function):
for modelable_entity in modelable_entities:
attributes = modelable_entity.attributes
nested_attribute_name_or_index = self.nested_attribute_name_or_index
- evaluation = get_modelable_entity_parameter(modelable_entity, attributes,
- nested_attribute_name_or_index)
+ evaluation = get_modelable_entity_parameter(attributes, nested_attribute_name_or_index)
if evaluation is not None:
evaluation.final = False # We never return final evaluations!
return evaluation
@@ -427,7 +429,7 @@ def parse_string_expression(context, presentation, name, index, explanation, val
if is_function:
return func
else:
- value = str(value)
+ value = unicode(value)
return value
@@ -642,7 +644,7 @@ def get_target(container_holder, name, locator):
return [container.target_node]
-def get_modelable_entity_parameter(modelable_entity, parameters, nested_parameter_name_or_index):
+def get_modelable_entity_parameter(parameters, nested_parameter_name_or_index):
if not parameters:
return Evaluation(None, True)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/__init__.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/__init__.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/__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/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_concat.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_concat.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_concat.py
new file mode 100644
index 0000000..23a274a
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_concat.py
@@ -0,0 +1,102 @@
+ # -*- 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.
+
+
+def test_functions_concat_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { concat: [] }
+""").assert_success()
+
+
+def test_functions_concat_strings(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { concat: [ a, b, c ] }
+""").assert_success()
+
+
+def test_functions_concat_mixed(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { concat: [ a, 1, 1.1, null, [], {} ] }
+""").assert_success()
+
+
+def test_functions_concat_nested(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { concat: [ a, { concat: [ b, c ] } ] }
+""").assert_success()
+
+
+# Unicode
+
+def test_functions_concat_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型:
+ properties:
+ 參數:
+ type: string
+topology_template:
+ node_templates:
+ 模板:
+ type: 類型
+ properties:
+ 參數: { concat: [ 一, 二, 三 ] }
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py
new file mode 100644
index 0000000..a590ed4
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_artifact.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_input.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_input.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_input.py
new file mode 100644
index 0000000..daaea5f
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_input.py
@@ -0,0 +1,94 @@
+# -*- 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.
+
+
+def test_functions_get_input_unknown(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { get_input: [ unknown ] }
+""").assert_failure()
+
+
+def test_functions_get_input(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ inputs:
+ my_input:
+ type: string
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { get_input: my_input }
+""").assert_success()
+
+
+def test_functions_get_input_nested(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ inputs:
+ my_input:
+ type: string
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { get_input: { concat: [ my, _, input ] } }
+""").assert_success()
+
+
+# Unicode
+
+def test_functions_get_input_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型:
+ properties:
+ 參數:
+ type: string
+topology_template:
+ inputs:
+ 输入:
+ type: string
+ node_templates:
+ 模板:
+ type: 類型
+ properties:
+ 參數: { get_input: 输入 }
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_nodes_of_type.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_nodes_of_type.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_nodes_of_type.py
new file mode 100644
index 0000000..a590ed4
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_nodes_of_type.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_operation_output.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_operation_output.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_operation_output.py
new file mode 100644
index 0000000..a590ed4
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_get_operation_output.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_token.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_token.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_token.py
new file mode 100644
index 0000000..8f99824
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_function_token.py
@@ -0,0 +1,119 @@
+# -*- 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.
+
+
+def test_functions_token_syntax_empty(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { token: [] } # needs exactly three args
+""").assert_failure()
+
+
+def test_functions_token_syntax_index_type(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { token: [ hello world, ' ', c ] }
+""").assert_failure()
+
+
+def test_functions_token_syntax_index_negative(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { token: [ hello world, ' ', -1 ] }
+""").assert_failure()
+
+
+def test_functions_token(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { token: [ hello world, ' ', 1 ] }
+""").assert_success()
+
+
+def test_functions_token_nested(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ properties:
+ my_parameter: { token: [ { token: [ hello/goodbye world, ' ', 0 ] }, '/', 1 ] }
+""").assert_success()
+
+
+# Unicode
+
+def test_functions_token_unicode(parser):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型:
+ properties:
+ 參數:
+ type: string
+topology_template:
+ node_templates:
+ 模板:
+ type: 類型
+ properties:
+ 參數: { token: [ '你好,世界', ',', 1 ] }
+""").assert_success()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/40a93457/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_functions_modelable_entity.py
----------------------------------------------------------------------
diff --git a/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_functions_modelable_entity.py b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_functions_modelable_entity.py
new file mode 100644
index 0000000..3d0c522
--- /dev/null
+++ b/tests/extensions/aria_extension_tosca/simple_v1_0/functions/test_functions_modelable_entity.py
@@ -0,0 +1,245 @@
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+
+# TODO other keywords (HOST, SOURCE, TARGET)
+# reqs and caps
+
+
+PERMUTATIONS = (
+ ('get_property', 'properties'),
+ ('get_attribute', 'attributes')
+)
+
+
+# Syntax
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_syntax_empty(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter: { {{ function }}: [] } # needs at least two args
+""", dict(function=function, section=section)).assert_failure()
+
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_syntax_single(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter: { {{ function }}: [ SELF ] } # needs at least two args
+""", dict(function=function, section=section)).assert_failure()
+
+
+# Entities
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_same(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ my_parameter2:
+ type: string
+ default: a value
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter1: { {{ function }}: [ my_node, my_parameter2 ] }
+""", dict(function=function, section=section)).assert_success()
+
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_other(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ my_parameter2:
+ type: string
+ default: a value
+topology_template:
+ node_templates:
+ my_node1:
+ type: MyType
+ {{ section }}:
+ my_parameter1: { {{ function }}: [ my_node2, my_parameter2 ] }
+ my_node2:
+ type: MyType
+ {{ section }}:
+ my_parameter1: a value
+""", dict(function=function, section=section)).assert_success()
+
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_unknown(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ properties:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter: { get_property: [ unknown, my_parameter ] }
+""", dict(function=function, section=section)).assert_failure()
+
+
+# Cyclical
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_cyclical_simple(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter: { {{ function }}: [ my_node, my_parameter ] }
+""", dict(function=function, section=section)).assert_failure()
+
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_cyclical_complex(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ my_parameter2:
+ type: string
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter1: { {{ function }}: [ my_node, my_parameter2 ] }
+ my_parameter2: { {{ function }}: [ my_node, my_parameter1 ] }
+""", dict(function=function, section=section)).assert_failure()
+
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_sub(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+data_types:
+ MyType:
+ properties:
+ my_field:
+ type: string
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ my_parameter2:
+ type: MyType
+ default:
+ my_field: a value
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter1: { {{ function }}: [ my_node, my_parameter2, my_field ] }
+""", dict(function=function, section=section)).assert_success()
+
+
+# Keywords
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_self(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ MyType:
+ {{ section }}:
+ my_parameter1:
+ type: string
+ my_parameter2:
+ type: string
+ default: a value
+topology_template:
+ node_templates:
+ my_node:
+ type: MyType
+ {{ section }}:
+ my_parameter1: { {{ function }}: [ SELF, my_parameter2 ] }
+""", dict(function=function, section=section)).assert_success()
+
+
+# Unicode
+
+@pytest.mark.parametrize('function,section', PERMUTATIONS)
+def test_functions_modelable_entity_unicode(parser, function, section):
+ parser.parse_literal("""
+tosca_definitions_version: tosca_simple_yaml_1_0
+node_types:
+ 類型:
+ {{ section }}:
+ 參數一:
+ type: string
+ 參數二:
+ type: string
+ default: 值
+topology_template:
+ node_templates:
+ 模板:
+ type: 類型
+ {{ section }}:
+ 參數一: { {{ function }}: [ 模板, 參數二 ] }
+""", dict(function=function, section=section)).assert_success()