vFW and vDNS support added to azure-plugin
[multicloud/azure.git] / azure / aria / aria-extension-cloudify / src / aria / tests / orchestrator / workflows / builtin / test_execute_operation.py
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
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15
16 import pytest
17
18 from aria.orchestrator.workflows.api import task
19 from aria.orchestrator.workflows.builtin.execute_operation import execute_operation
20
21 from tests import mock, storage
22
23
24 @pytest.fixture
25 def ctx(tmpdir):
26     context = mock.context.simple(str(tmpdir), inmemory=False)
27     yield context
28     storage.release_sqlite_storage(context.model)
29
30
31 def test_execute_operation(ctx):
32     node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
33     interface_name, operation_name = mock.operations.NODE_OPERATIONS_INSTALL[0]
34     interface = mock.models.create_interface(
35         ctx.service,
36         interface_name,
37         operation_name,
38         operation_kwargs=dict(function='test')
39     )
40     node.interfaces[interface.name] = interface
41     ctx.model.node.update(node)
42
43     execute_tasks = list(
44         task.WorkflowTask(
45             execute_operation,
46             ctx=ctx,
47             interface_name=interface_name,
48             operation_name=operation_name,
49             operation_kwargs={},
50             allow_kwargs_override=False,
51             run_by_dependency_order=False,
52             type_names=[],
53             node_template_ids=[],
54             node_ids=[node.id]
55         ).topological_order()
56     )
57
58     assert len(execute_tasks) == 1
59     assert getattr(execute_tasks[0].actor, '_wrapped', execute_tasks[0].actor) == node
60     assert execute_tasks[0].operation_name == operation_name
61     assert execute_tasks[0].interface_name == interface_name
62
63
64 # TODO: add more scenarios