ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject [4/7] incubator-ariatosca git commit: Aria 21 reorder repository sturcutre
Date Wed, 16 Nov 2016 10:52:49 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/artifacts.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/artifacts.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/artifacts.py
index f28f429..f5667a6 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/artifacts.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/artifacts.py
@@ -13,7 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from collections import OrderedDict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 #
 # NodeType, NodeTemplate

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
index f9e293d..4a96b04 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py
@@ -13,7 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from collections import OrderedDict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 from aria.parser.utils import deepcopy_with_locators
 from aria.parser.validation import Issue

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
index 9b0edb8..d98bc54 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py
@@ -14,7 +14,10 @@
 # limitations under the License.
 
 import re
-from collections import OrderedDict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 from aria.parser import dsl_specification
 from aria.parser.presentation import (get_locator, validate_primitive)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
index 1d734cf..bffb5dc 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py
@@ -13,7 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from collections import OrderedDict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 from aria.parser.presentation import get_locator
 from aria.parser.utils import (merge, deepcopy_with_locators)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
index d803609..439f44c 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/properties.py
@@ -13,7 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from collections import OrderedDict
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 
 from aria.parser.presentation import Value
 from aria.parser.utils import (merge, deepcopy_with_locators)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
index 721ea09..068dde0 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py
@@ -13,8 +13,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from collections import OrderedDict
-
+try:
+    from collections import OrderedDict
+except ImportError:
+    from ordereddict import OrderedDict
 from aria.parser.validation import Issue
 from aria.parser.utils import deepcopy_with_locators
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/context/__init__.py
----------------------------------------------------------------------
diff --git a/tests/context/__init__.py b/tests/context/__init__.py
deleted file mode 100644
index afd5cd7..0000000
--- a/tests/context/__init__.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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 sys
-
-import pytest
-
-from aria.workflows.core import engine
-
-
-def op_path(func, module_path=None):
-    module_path = module_path or sys.modules[__name__].__name__
-    return '{0}.{1}'.format(module_path, func.__name__)
-
-
-def op_name(actor, operation_name):
-    return '{name}.{actor.id}'.format(name=operation_name, actor=actor)
-
-
-def execute(workflow_func, workflow_context, executor):
-    graph = workflow_func(ctx=workflow_context)
-    eng = engine.Engine(executor=executor, workflow_context=workflow_context, tasks_graph=graph)
-    eng.execute()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/context/test_operation.py b/tests/context/test_operation.py
deleted file mode 100644
index 0c34a0f..0000000
--- a/tests/context/test_operation.py
+++ /dev/null
@@ -1,156 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import pytest
-
-from aria import (
-    workflow,
-    operation,
-    context,
-)
-from aria.workflows import api
-from aria.workflows.executor import thread
-
-from .. import mock
-from . import (
-    op_path,
-    op_name,
-    execute,
-)
-
-global_test_holder = {}
-
-
-@pytest.fixture
-def ctx():
-    return mock.context.simple()
-
-
-@pytest.fixture
-def executor():
-    result = thread.ThreadExecutor()
-    try:
-        yield result
-    finally:
-        result.close()
-
-
-def test_node_operation_task_execution(ctx, executor):
-    operation_name = 'aria.interfaces.lifecycle.create'
-
-    node = mock.models.get_dependency_node()
-    node.operations[operation_name] = {
-        'operation': op_path(my_operation, module_path=__name__)
-
-    }
-    node_instance = mock.models.get_dependency_node_instance(node)
-    ctx.model.node.store(node)
-    ctx.model.node_instance.store(node_instance)
-
-    inputs = {'putput': True}
-
-    @workflow
-    def basic_workflow(graph, **_):
-        graph.add_tasks(
-            api.task.OperationTask.node_instance(
-                name=operation_name,
-                instance=node_instance,
-                inputs=inputs
-            )
-        )
-
-    execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
-
-    operation_context = global_test_holder[op_name(node_instance, operation_name)]
-
-    assert isinstance(operation_context, context.operation.NodeOperationContext)
-
-    # Task bases assertions
-    assert operation_context.task.actor == node_instance
-    assert operation_context.task.name == op_name(node_instance, operation_name)
-    assert operation_context.task.operation_mapping == node.operations[operation_name]['operation']
-    assert operation_context.task.inputs == inputs
-
-    # Context based attributes (sugaring)
-    assert operation_context.node == node_instance.node
-    assert operation_context.node_instance == node_instance
-
-
-def test_relationship_operation_task_execution(ctx, executor):
-    operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
-
-    dependency_node = mock.models.get_dependency_node()
-    dependency_node_instance = mock.models.get_dependency_node_instance()
-    relationship = mock.models.get_relationship(target=dependency_node)
-    relationship.source_operations[operation_name] = {
-        'operation': op_path(my_operation, module_path=__name__)
-    }
-    relationship_instance = mock.models.get_relationship_instance(
-        target_instance=dependency_node_instance,
-        relationship=relationship)
-    dependent_node = mock.models.get_dependent_node()
-    dependent_node_instance = mock.models.get_dependent_node_instance(
-        relationship_instance=relationship_instance,
-        dependent_node=dependency_node)
-    ctx.model.node.store(dependency_node)
-    ctx.model.node_instance.store(dependency_node_instance)
-    ctx.model.relationship.store(relationship)
-    ctx.model.relationship_instance.store(relationship_instance)
-    ctx.model.node.store(dependent_node)
-    ctx.model.node_instance.store(dependent_node_instance)
-
-    inputs = {'putput': True}
-
-    @workflow
-    def basic_workflow(graph, **_):
-        graph.add_tasks(
-            api.task.OperationTask.relationship_instance(
-                instance=relationship_instance,
-                name=operation_name,
-                operation_end=api.task.OperationTask.SOURCE_OPERATION,
-                inputs=inputs
-            )
-        )
-
-    execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
-
-    operation_context = global_test_holder[op_name(relationship_instance, operation_name)]
-
-    assert isinstance(operation_context, context.operation.RelationshipOperationContext)
-
-    # Task bases assertions
-    assert operation_context.task.actor == relationship_instance
-    assert operation_context.task.name == op_name(relationship_instance, operation_name)
-    assert operation_context.task.operation_mapping == \
-           relationship.source_operations[operation_name]['operation']
-    assert operation_context.task.inputs == inputs
-
-    # Context based attributes (sugaring)
-    assert operation_context.target_node == dependency_node
-    assert operation_context.target_node_instance == dependency_node_instance
-    assert operation_context.relationship == relationship
-    assert operation_context.relationship_instance == relationship_instance
-    assert operation_context.source_node == dependent_node
-    assert operation_context.source_node_instance == dependent_node_instance
-
-
-@operation
-def my_operation(ctx, **_):
-    global_test_holder[ctx.name] = ctx
-
-
-@pytest.fixture(autouse=True)
-def cleanup():
-    global_test_holder.clear()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/context/test_toolbelt.py b/tests/context/test_toolbelt.py
deleted file mode 100644
index 4288ce9..0000000
--- a/tests/context/test_toolbelt.py
+++ /dev/null
@@ -1,171 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import pytest
-
-from aria import workflow, operation, context
-from aria.workflows import api
-from aria.workflows.executor import thread
-from aria.context.toolbelt import RelationshipToolBelt
-
-from .. import mock
-from . import (
-    op_path,
-    op_name,
-    execute,
-)
-
-global_test_holder = {}
-
-
-@pytest.fixture
-def workflow_context():
-    return mock.context.simple()
-
-
-@pytest.fixture
-def executor():
-    result = thread.ThreadExecutor()
-    try:
-        yield result
-    finally:
-        result.close()
-
-
-def _create_simple_model_in_storage(workflow_context):
-    dependency_node = mock.models.get_dependency_node()
-    dependency_node_instance = mock.models.get_dependency_node_instance(
-        dependency_node=dependency_node)
-    relationship = mock.models.get_relationship(target=dependency_node)
-    relationship_instance = mock.models.get_relationship_instance(
-        target_instance=dependency_node_instance, relationship=relationship)
-    dependent_node = mock.models.get_dependent_node()
-    dependent_node_instance = mock.models.get_dependent_node_instance(
-        relationship_instance=relationship_instance, dependent_node=dependency_node)
-    workflow_context.model.node.store(dependency_node)
-    workflow_context.model.node_instance.store(dependency_node_instance)
-    workflow_context.model.relationship.store(relationship)
-    workflow_context.model.relationship_instance.store(relationship_instance)
-    workflow_context.model.node.store(dependent_node)
-    workflow_context.model.node_instance.store(dependent_node_instance)
-    return dependency_node, dependency_node_instance, \
-           dependent_node, dependent_node_instance, \
-           relationship, relationship_instance
-
-
-def test_host_ip(workflow_context, executor):
-    operation_name = 'aria.interfaces.lifecycle.create'
-    dependency_node, dependency_node_instance, _, _, _, _ = \
-        _create_simple_model_in_storage(workflow_context)
-    dependency_node.operations[operation_name] = {
-        'operation': op_path(host_ip, module_path=__name__)
-
-    }
-    workflow_context.model.node.store(dependency_node)
-    inputs = {'putput': True}
-
-    @workflow
-    def basic_workflow(graph, **_):
-        graph.add_tasks(
-            api.task.OperationTask.node_instance(
-                instance=dependency_node_instance,
-                name=operation_name,
-                inputs=inputs
-            )
-        )
-
-    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
-    assert global_test_holder.get('host_ip') == \
-           dependency_node_instance.runtime_properties.get('ip')
-
-
-def test_dependent_node_instances(workflow_context, executor):
-    operation_name = 'aria.interfaces.lifecycle.create'
-    dependency_node, dependency_node_instance, _, dependent_node_instance, _, _ = \
-        _create_simple_model_in_storage(workflow_context)
-    dependency_node.operations[operation_name] = {
-        'operation': op_path(dependent_nodes, module_path=__name__)
-
-    }
-    workflow_context.model.node.store(dependency_node)
-    inputs = {'putput': True}
-
-    @workflow
-    def basic_workflow(graph, **_):
-        graph.add_tasks(
-            api.task.OperationTask.node_instance(
-                instance=dependency_node_instance,
-                name=operation_name,
-                inputs=inputs
-            )
-        )
-
-    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
-    assert list(global_test_holder.get('dependent_node_instances', [])) == \
-           list([dependent_node_instance])
-
-
-def test_relationship_tool_belt(workflow_context, executor):
-    operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
-    _, _, _, _, relationship, relationship_instance = \
-        _create_simple_model_in_storage(workflow_context)
-    relationship.source_operations[operation_name] = {
-        'operation': op_path(relationship_operation, module_path=__name__)
-    }
-    workflow_context.model.relationship.store(relationship)
-
-    inputs = {'putput': True}
-
-    @workflow
-    def basic_workflow(graph, **_):
-        graph.add_tasks(
-            api.task.OperationTask.relationship_instance(
-                instance=relationship_instance,
-                name=operation_name,
-                operation_end=api.task.OperationTask.SOURCE_OPERATION,
-                inputs=inputs
-            )
-        )
-
-    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
-
-    assert isinstance(global_test_holder.get(op_name(relationship_instance, operation_name)),
-                      RelationshipToolBelt)
-
-
-def test_wrong_model_toolbelt():
-    with pytest.raises(RuntimeError):
-        context.toolbelt(None)
-
-@operation(toolbelt=True)
-def host_ip(toolbelt, **_):
-    global_test_holder['host_ip'] = toolbelt.host_ip
-
-
-@operation(toolbelt=True)
-def dependent_nodes(toolbelt, **_):
-    global_test_holder['dependent_node_instances'] = list(toolbelt.dependent_node_instances)
-
-
-@operation(toolbelt=True)
-def relationship_operation(ctx, toolbelt, **_):
-    global_test_holder[ctx.name] = toolbelt
-
-
-@pytest.fixture(autouse=True)
-def cleanup():
-    global_test_holder.clear()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/context/test_workflow.py b/tests/context/test_workflow.py
deleted file mode 100644
index 4b71855..0000000
--- a/tests/context/test_workflow.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# 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.
-
-from datetime import datetime
-
-import pytest
-
-from aria import context, application_model_storage
-
-from ..mock import models
-from ..storage import InMemoryModelDriver
-
-
-class TestWorkflowContext(object):
-
-    def test_execution_creation_on_workflow_context_creation(self, storage):
-        self._create_ctx(storage)
-        execution = storage.execution.get(models.EXECUTION_ID)
-        assert execution.id == models.EXECUTION_ID
-        assert execution.deployment_id == models.DEPLOYMENT_ID
-        assert execution.workflow_id == models.WORKFLOW_ID
-        assert execution.blueprint_id == models.BLUEPRINT_ID
-        assert execution.status == storage.execution.model_cls.PENDING
-        assert execution.parameters == {}
-        assert execution.created_at <= datetime.utcnow()
-
-    def test_subsequent_workflow_context_creation_do_not_fail(self, storage):
-        self._create_ctx(storage)
-        self._create_ctx(storage)
-
-    @staticmethod
-    def _create_ctx(storage):
-        return context.workflow.WorkflowContext(
-            name='simple_context',
-            model_storage=storage,
-            resource_storage=None,
-            deployment_id=models.DEPLOYMENT_ID,
-            workflow_id=models.WORKFLOW_ID,
-            execution_id=models.EXECUTION_ID,
-            task_max_attempts=models.TASK_MAX_ATTEMPTS,
-            task_retry_interval=models.TASK_RETRY_INTERVAL
-        )
-
-
-@pytest.fixture(scope='function')
-def storage():
-    result = application_model_storage(InMemoryModelDriver())
-    result.setup()
-    result.deployment.store(models.get_deployment())
-    return result

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/events/__init__.py
----------------------------------------------------------------------
diff --git a/tests/events/__init__.py b/tests/events/__init__.py
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/events/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/17510b02/tests/events/test_builtin_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/events/test_builtin_event_handlers.py b/tests/events/test_builtin_event_handlers.py
deleted file mode 100644
index ae1e83e..0000000
--- a/tests/events/test_builtin_event_handlers.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/17510b02/tests/events/test_workflow_enginge_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/events/test_workflow_enginge_event_handlers.py b/tests/events/test_workflow_enginge_event_handlers.py
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/mock/context.py
----------------------------------------------------------------------
diff --git a/tests/mock/context.py b/tests/mock/context.py
index c48ed9a..5fda07e 100644
--- a/tests/mock/context.py
+++ b/tests/mock/context.py
@@ -13,7 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from aria import context, application_model_storage
+from aria import application_model_storage
+from aria.orchestrator import context
 
 from . import models
 from ..storage import InMemoryModelDriver

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/__init__.py b/tests/orchestrator/__init__.py
new file mode 100644
index 0000000..13878a1
--- /dev/null
+++ b/tests/orchestrator/__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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/context/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/__init__.py b/tests/orchestrator/context/__init__.py
new file mode 100644
index 0000000..ea0fea9
--- /dev/null
+++ b/tests/orchestrator/context/__init__.py
@@ -0,0 +1,33 @@
+# 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 sys
+
+from aria.orchestrator.workflows.core import engine
+
+
+def op_path(func, module_path=None):
+    module_path = module_path or sys.modules[__name__].__name__
+    return '{0}.{1}'.format(module_path, func.__name__)
+
+
+def op_name(actor, operation_name):
+    return '{name}.{actor.id}'.format(name=operation_name, actor=actor)
+
+
+def execute(workflow_func, workflow_context, executor):
+    graph = workflow_func(ctx=workflow_context)
+    eng = engine.Engine(executor=executor, workflow_context=workflow_context, tasks_graph=graph)
+    eng.execute()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
new file mode 100644
index 0000000..6b3e28d
--- /dev/null
+++ b/tests/orchestrator/context/test_operation.py
@@ -0,0 +1,156 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+from aria import (
+    workflow,
+    operation,
+)
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+from aria.orchestrator.workflows.executor import thread
+
+from tests import mock
+from . import (
+    op_path,
+    op_name,
+    execute,
+)
+
+global_test_holder = {}
+
+
+@pytest.fixture
+def ctx():
+    return mock.context.simple()
+
+
+@pytest.fixture
+def executor():
+    result = thread.ThreadExecutor()
+    try:
+        yield result
+    finally:
+        result.close()
+
+
+def test_node_operation_task_execution(ctx, executor):
+    operation_name = 'aria.interfaces.lifecycle.create'
+
+    node = mock.models.get_dependency_node()
+    node.operations[operation_name] = {
+        'operation': op_path(my_operation, module_path=__name__)
+
+    }
+    node_instance = mock.models.get_dependency_node_instance(node)
+    ctx.model.node.store(node)
+    ctx.model.node_instance.store(node_instance)
+
+    inputs = {'putput': True}
+
+    @workflow
+    def basic_workflow(graph, **_):
+        graph.add_tasks(
+            api.task.OperationTask.node_instance(
+                name=operation_name,
+                instance=node_instance,
+                inputs=inputs
+            )
+        )
+
+    execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
+
+    operation_context = global_test_holder[op_name(node_instance, operation_name)]
+
+    assert isinstance(operation_context, context.operation.NodeOperationContext)
+
+    # Task bases assertions
+    assert operation_context.task.actor == node_instance
+    assert operation_context.task.name == op_name(node_instance, operation_name)
+    assert operation_context.task.operation_mapping == node.operations[operation_name]['operation']
+    assert operation_context.task.inputs == inputs
+
+    # Context based attributes (sugaring)
+    assert operation_context.node == node_instance.node
+    assert operation_context.node_instance == node_instance
+
+
+def test_relationship_operation_task_execution(ctx, executor):
+    operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
+
+    dependency_node = mock.models.get_dependency_node()
+    dependency_node_instance = mock.models.get_dependency_node_instance()
+    relationship = mock.models.get_relationship(target=dependency_node)
+    relationship.source_operations[operation_name] = {
+        'operation': op_path(my_operation, module_path=__name__)
+    }
+    relationship_instance = mock.models.get_relationship_instance(
+        target_instance=dependency_node_instance,
+        relationship=relationship)
+    dependent_node = mock.models.get_dependent_node()
+    dependent_node_instance = mock.models.get_dependent_node_instance(
+        relationship_instance=relationship_instance,
+        dependent_node=dependency_node)
+    ctx.model.node.store(dependency_node)
+    ctx.model.node_instance.store(dependency_node_instance)
+    ctx.model.relationship.store(relationship)
+    ctx.model.relationship_instance.store(relationship_instance)
+    ctx.model.node.store(dependent_node)
+    ctx.model.node_instance.store(dependent_node_instance)
+
+    inputs = {'putput': True}
+
+    @workflow
+    def basic_workflow(graph, **_):
+        graph.add_tasks(
+            api.task.OperationTask.relationship_instance(
+                instance=relationship_instance,
+                name=operation_name,
+                operation_end=api.task.OperationTask.SOURCE_OPERATION,
+                inputs=inputs
+            )
+        )
+
+    execute(workflow_func=basic_workflow, workflow_context=ctx, executor=executor)
+
+    operation_context = global_test_holder[op_name(relationship_instance, operation_name)]
+
+    assert isinstance(operation_context, context.operation.RelationshipOperationContext)
+
+    # Task bases assertions
+    assert operation_context.task.actor == relationship_instance
+    assert operation_context.task.name == op_name(relationship_instance, operation_name)
+    assert operation_context.task.operation_mapping == \
+           relationship.source_operations[operation_name]['operation']
+    assert operation_context.task.inputs == inputs
+
+    # Context based attributes (sugaring)
+    assert operation_context.target_node == dependency_node
+    assert operation_context.target_node_instance == dependency_node_instance
+    assert operation_context.relationship == relationship
+    assert operation_context.relationship_instance == relationship_instance
+    assert operation_context.source_node == dependent_node
+    assert operation_context.source_node_instance == dependent_node_instance
+
+
+@operation
+def my_operation(ctx, **_):
+    global_test_holder[ctx.name] = ctx
+
+
+@pytest.fixture(autouse=True)
+def cleanup():
+    global_test_holder.clear()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py
new file mode 100644
index 0000000..547e62b
--- /dev/null
+++ b/tests/orchestrator/context/test_toolbelt.py
@@ -0,0 +1,172 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+from aria import workflow, operation
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+from aria.orchestrator.workflows.executor import thread
+from aria.orchestrator.context.toolbelt import RelationshipToolBelt
+
+from tests import mock
+from . import (
+    op_path,
+    op_name,
+    execute,
+)
+
+global_test_holder = {}
+
+
+@pytest.fixture
+def workflow_context():
+    return mock.context.simple()
+
+
+@pytest.fixture
+def executor():
+    result = thread.ThreadExecutor()
+    try:
+        yield result
+    finally:
+        result.close()
+
+
+def _create_simple_model_in_storage(workflow_context):
+    dependency_node = mock.models.get_dependency_node()
+    dependency_node_instance = mock.models.get_dependency_node_instance(
+        dependency_node=dependency_node)
+    relationship = mock.models.get_relationship(target=dependency_node)
+    relationship_instance = mock.models.get_relationship_instance(
+        target_instance=dependency_node_instance, relationship=relationship)
+    dependent_node = mock.models.get_dependent_node()
+    dependent_node_instance = mock.models.get_dependent_node_instance(
+        relationship_instance=relationship_instance, dependent_node=dependency_node)
+    workflow_context.model.node.store(dependency_node)
+    workflow_context.model.node_instance.store(dependency_node_instance)
+    workflow_context.model.relationship.store(relationship)
+    workflow_context.model.relationship_instance.store(relationship_instance)
+    workflow_context.model.node.store(dependent_node)
+    workflow_context.model.node_instance.store(dependent_node_instance)
+    return dependency_node, dependency_node_instance, \
+           dependent_node, dependent_node_instance, \
+           relationship, relationship_instance
+
+
+def test_host_ip(workflow_context, executor):
+    operation_name = 'aria.interfaces.lifecycle.create'
+    dependency_node, dependency_node_instance, _, _, _, _ = \
+        _create_simple_model_in_storage(workflow_context)
+    dependency_node.operations[operation_name] = {
+        'operation': op_path(host_ip, module_path=__name__)
+
+    }
+    workflow_context.model.node.store(dependency_node)
+    inputs = {'putput': True}
+
+    @workflow
+    def basic_workflow(graph, **_):
+        graph.add_tasks(
+            api.task.OperationTask.node_instance(
+                instance=dependency_node_instance,
+                name=operation_name,
+                inputs=inputs
+            )
+        )
+
+    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+    assert global_test_holder.get('host_ip') == \
+           dependency_node_instance.runtime_properties.get('ip')
+
+
+def test_dependent_node_instances(workflow_context, executor):
+    operation_name = 'aria.interfaces.lifecycle.create'
+    dependency_node, dependency_node_instance, _, dependent_node_instance, _, _ = \
+        _create_simple_model_in_storage(workflow_context)
+    dependency_node.operations[operation_name] = {
+        'operation': op_path(dependent_nodes, module_path=__name__)
+
+    }
+    workflow_context.model.node.store(dependency_node)
+    inputs = {'putput': True}
+
+    @workflow
+    def basic_workflow(graph, **_):
+        graph.add_tasks(
+            api.task.OperationTask.node_instance(
+                instance=dependency_node_instance,
+                name=operation_name,
+                inputs=inputs
+            )
+        )
+
+    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+    assert list(global_test_holder.get('dependent_node_instances', [])) == \
+           list([dependent_node_instance])
+
+
+def test_relationship_tool_belt(workflow_context, executor):
+    operation_name = 'aria.interfaces.relationship_lifecycle.postconfigure'
+    _, _, _, _, relationship, relationship_instance = \
+        _create_simple_model_in_storage(workflow_context)
+    relationship.source_operations[operation_name] = {
+        'operation': op_path(relationship_operation, module_path=__name__)
+    }
+    workflow_context.model.relationship.store(relationship)
+
+    inputs = {'putput': True}
+
+    @workflow
+    def basic_workflow(graph, **_):
+        graph.add_tasks(
+            api.task.OperationTask.relationship_instance(
+                instance=relationship_instance,
+                name=operation_name,
+                operation_end=api.task.OperationTask.SOURCE_OPERATION,
+                inputs=inputs
+            )
+        )
+
+    execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor)
+
+    assert isinstance(global_test_holder.get(op_name(relationship_instance, operation_name)),
+                      RelationshipToolBelt)
+
+
+def test_wrong_model_toolbelt():
+    with pytest.raises(RuntimeError):
+        context.toolbelt(None)
+
+@operation(toolbelt=True)
+def host_ip(toolbelt, **_):
+    global_test_holder['host_ip'] = toolbelt.host_ip
+
+
+@operation(toolbelt=True)
+def dependent_nodes(toolbelt, **_):
+    global_test_holder['dependent_node_instances'] = list(toolbelt.dependent_node_instances)
+
+
+@operation(toolbelt=True)
+def relationship_operation(ctx, toolbelt, **_):
+    global_test_holder[ctx.name] = toolbelt
+
+
+@pytest.fixture(autouse=True)
+def cleanup():
+    global_test_holder.clear()

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_workflow.py b/tests/orchestrator/context/test_workflow.py
new file mode 100644
index 0000000..19eb57c
--- /dev/null
+++ b/tests/orchestrator/context/test_workflow.py
@@ -0,0 +1,63 @@
+# 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.
+
+from datetime import datetime
+
+import pytest
+
+from aria import application_model_storage
+from aria.orchestrator import context
+
+from tests.mock import models
+from tests.storage import InMemoryModelDriver
+
+
+class TestWorkflowContext(object):
+
+    def test_execution_creation_on_workflow_context_creation(self, storage):
+        self._create_ctx(storage)
+        execution = storage.execution.get(models.EXECUTION_ID)
+        assert execution.id == models.EXECUTION_ID
+        assert execution.deployment_id == models.DEPLOYMENT_ID
+        assert execution.workflow_id == models.WORKFLOW_ID
+        assert execution.blueprint_id == models.BLUEPRINT_ID
+        assert execution.status == storage.execution.model_cls.PENDING
+        assert execution.parameters == {}
+        assert execution.created_at <= datetime.utcnow()
+
+    def test_subsequent_workflow_context_creation_do_not_fail(self, storage):
+        self._create_ctx(storage)
+        self._create_ctx(storage)
+
+    @staticmethod
+    def _create_ctx(storage):
+        return context.workflow.WorkflowContext(
+            name='simple_context',
+            model_storage=storage,
+            resource_storage=None,
+            deployment_id=models.DEPLOYMENT_ID,
+            workflow_id=models.WORKFLOW_ID,
+            execution_id=models.EXECUTION_ID,
+            task_max_attempts=models.TASK_MAX_ATTEMPTS,
+            task_retry_interval=models.TASK_RETRY_INTERVAL
+        )
+
+
+@pytest.fixture(scope='function')
+def storage():
+    result = application_model_storage(InMemoryModelDriver())
+    result.setup()
+    result.deployment.store(models.get_deployment())
+    return result

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/events/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/__init__.py b/tests/orchestrator/events/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/events/__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/17510b02/tests/orchestrator/events/test_builtin_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/test_builtin_event_handlers.py b/tests/orchestrator/events/test_builtin_event_handlers.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/events/test_builtin_event_handlers.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/17510b02/tests/orchestrator/events/test_workflow_enginge_event_handlers.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/events/test_workflow_enginge_event_handlers.py b/tests/orchestrator/events/test_workflow_enginge_event_handlers.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/workflows/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/__init__.py b/tests/orchestrator/workflows/__init__.py
new file mode 100644
index 0000000..fe04b2f
--- /dev/null
+++ b/tests/orchestrator/workflows/__init__.py
@@ -0,0 +1,16 @@
+# 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.
+
+from . import api, builtin, core

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17510b02/tests/orchestrator/workflows/api/__init__.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/api/__init__.py b/tests/orchestrator/workflows/api/__init__.py
new file mode 100644
index 0000000..ae1e83e
--- /dev/null
+++ b/tests/orchestrator/workflows/api/__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/17510b02/tests/orchestrator/workflows/api/test_task.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/api/test_task.py b/tests/orchestrator/workflows/api/test_task.py
new file mode 100644
index 0000000..8536902
--- /dev/null
+++ b/tests/orchestrator/workflows/api/test_task.py
@@ -0,0 +1,150 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import pytest
+
+from aria.orchestrator import context
+from aria.orchestrator.workflows import api
+
+from tests import mock
+
+
+@pytest.fixture()
+def ctx():
+    """
+    Create the following graph in storage:
+    dependency_node <------ dependent_node
+    :return:
+    """
+    simple_context = mock.context.simple()
+    dependency_node = mock.models.get_dependency_node()
+    dependency_node_instance = mock.models.get_dependency_node_instance(
+        dependency_node=dependency_node)
+
+    relationship = mock.models.get_relationship(dependency_node)
+    relationship_instance = mock.models.get_relationship_instance(
+        relationship=relationship,
+        target_instance=dependency_node_instance
+    )
+
+    dependent_node = mock.models.get_dependent_node(relationship)
+    dependent_node_instance = mock.models.get_dependent_node_instance(
+        dependent_node=dependent_node,
+        relationship_instance=relationship_instance
+    )
+
+    simple_context.model.node.store(dependent_node)
+    simple_context.model.node.store(dependency_node)
+    simple_context.model.node_instance.store(dependent_node_instance)
+    simple_context.model.node_instance.store(dependency_node_instance)
+    simple_context.model.relationship.store(relationship)
+    simple_context.model.relationship_instance.store(relationship_instance)
+    simple_context.model.execution.store(mock.models.get_execution())
+    simple_context.model.deployment.store(mock.models.get_deployment())
+
+    return simple_context
+
+
+class TestOperationTask(object):
+
+    def test_node_operation_task_creation(self):
+        workflow_context = mock.context.simple()
+
+        operation_name = 'aria.interfaces.lifecycle.create'
+        op_details = {'operation': True}
+        node = mock.models.get_dependency_node()
+        node.operations[operation_name] = op_details
+        node_instance = mock.models.get_dependency_node_instance(dependency_node=node)
+        inputs = {'inputs': True}
+        max_attempts = 10
+        retry_interval = 10
+        ignore_failure = True
+
+        with context.workflow.current.push(workflow_context):
+            api_task = api.task.OperationTask.node_instance(
+                name=operation_name,
+                instance=node_instance,
+                inputs=inputs,
+                max_attempts=max_attempts,
+                retry_interval=retry_interval,
+                ignore_failure=ignore_failure)
+
+        assert api_task.name == '{0}.{1}'.format(operation_name, node_instance.id)
+        assert api_task.operation_mapping is True
+        assert api_task.actor == node_instance
+        assert api_task.inputs == inputs
+        assert api_task.retry_interval == retry_interval
+        assert api_task.max_attempts == max_attempts
+        assert api_task.ignore_failure == ignore_failure
+
+    def test_relationship_operation_task_creation(self):
+        workflow_context = mock.context.simple()
+
+        operation_name = 'aria.interfaces.relationship_lifecycle.preconfigure'
+        op_details = {'operation': True}
+        relationship = mock.models.get_relationship()
+        relationship.source_operations[operation_name] = op_details
+        relationship_instance = mock.models.get_relationship_instance(relationship=relationship)
+        inputs = {'inputs': True}
+        max_attempts = 10
+        retry_interval = 10
+
+        with context.workflow.current.push(workflow_context):
+            api_task = api.task.OperationTask.relationship_instance(
+                name=operation_name,
+                instance=relationship_instance,
+                operation_end=api.task.OperationTask.SOURCE_OPERATION,
+                inputs=inputs,
+                max_attempts=max_attempts,
+                retry_interval=retry_interval)
+
+        assert api_task.name == '{0}.{1}'.format(operation_name, relationship_instance.id)
+        assert api_task.operation_mapping is True
+        assert api_task.actor == relationship_instance
+        assert api_task.inputs == inputs
+        assert api_task.retry_interval == retry_interval
+        assert api_task.max_attempts == max_attempts
+
+    def test_operation_task_default_values(self):
+        workflow_context = mock.context.simple(task_ignore_failure=True)
+        with context.workflow.current.push(workflow_context):
+            model_task = api.task.OperationTask(
+                name='stub',
+                operation_mapping='',
+                actor=mock.models.get_dependency_node_instance())
+
+        assert model_task.inputs == {}
+        assert model_task.retry_interval == workflow_context._task_retry_interval
+        assert model_task.max_attempts == workflow_context._task_max_attempts
+        assert model_task.ignore_failure == workflow_context._task_ignore_failure
+
+
+class TestWorkflowTask(object):
+
+    def test_workflow_task_creation(self, ctx):
+
+        workspace = {}
+
+        mock_class = type('mock_class', (object,), {'test_attribute': True})
+
+        def sub_workflow(**kwargs):
+            workspace.update(kwargs)
+            return mock_class
+
+        with context.workflow.current.push(ctx):
+            workflow_task = api.task.WorkflowTask(sub_workflow, kwarg='workflow_kwarg')
+            assert workflow_task.graph is mock_class
+            assert workflow_task.test_attribute is True


Mime
View raw message