1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 from tests.parser.service_templates import consume_literal
19 from aria.modeling.utils import parameters_as_values
23 tosca_definitions_version: tosca_simple_yaml_1_0
27 derived_from: tosca.interfaces.Root
36 implementation: operation.sh
44 interface_integer: # will override interface input
50 derived_from: tosca.nodes.Root
56 derived_from: tosca.nodes.Compute
72 tosca_definitions_version: tosca_simple_yaml_1_0
76 derived_from: tosca.interfaces.Root
85 implementation: operation.sh
90 toolbelt: # reserved name
96 derived_from: tosca.nodes.Root
110 context, _ = consume_literal(TEMPLATE)
111 yield context.modeling.instance
115 def broken_service_issues():
116 context, _ = consume_literal(BROKEN_TEMPLATE, no_issues=False)
117 yield context.validation.issues
120 def test_local(service):
121 interface = service.nodes['local_node_1'].interfaces['MyInterface']
122 operation = interface.operations['operation']
123 assert parameters_as_values(interface.inputs) == {
124 'interface_string': 'value1',
125 'interface_integer': 1
127 assert parameters_as_values(operation.inputs) == {
128 'operation_string': 'value2',
129 'operation_integer': 2,
130 'interface_integer': 3
132 assert parameters_as_values(operation.arguments) == {
134 'script_path': 'operation.sh',
135 'interface_string': 'value1',
136 'interface_integer': 3,
137 'operation_string': 'value2',
138 'operation_integer': 2
142 def test_remote(service):
143 interface = service.nodes['remote_node_1'].interfaces['MyInterface']
144 operation = interface.operations['operation']
145 assert parameters_as_values(interface.inputs) == {
146 'interface_string': 'value1',
147 'interface_integer': 1
149 assert parameters_as_values(operation.inputs) == {
150 'operation_string': 'value2',
151 'operation_integer': 2,
152 'interface_integer': 3
154 assert parameters_as_values(operation.arguments) == {
157 'fabric_env': {'user': '', 'password': '', 'key': None, 'key_filename': None},
158 'script_path': 'operation.sh',
160 'interface_string': 'value1',
161 'interface_integer': 3,
162 'operation_string': 'value2',
163 'operation_integer': 2
167 def test_reserved_arguments(broken_service_issues):
168 assert len(broken_service_issues) == 1
169 message = broken_service_issues[0].message
170 assert message.startswith('using reserved arguments in operation "operation":')
171 assert '"ctx"' in message
172 assert '"toolbelt"' in message