ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: code review [maxim]
Date Mon, 07 Nov 2016 13:16:53 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-3-api-for-creating-workflows e1ca5c299 -> 45da7263c


code review [maxim]


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/45da7263
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/45da7263
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/45da7263

Branch: refs/heads/ARIA-3-api-for-creating-workflows
Commit: 45da7263cb1e4cf02049fe95c4ea4db6bd3aac22
Parents: e1ca5c2
Author: mxmrlv <mxmrlv@gmail.com>
Authored: Mon Nov 7 15:16:39 2016 +0200
Committer: mxmrlv <mxmrlv@gmail.com>
Committed: Mon Nov 7 15:16:39 2016 +0200

----------------------------------------------------------------------
 aria/.pylintrc                                  | 17 +++++++-
 aria/context/workflow.py                        | 35 ++++++++--------
 aria/decorators.py                              | 14 +++----
 aria/storage/models.py                          |  2 +-
 aria/workflows/api/task.py                      | 43 +++++++++++---------
 aria/workflows/api/task_graph.py                |  9 ++--
 aria/workflows/builtin/heal.py                  |  7 +---
 aria/workflows/builtin/workflows.py             |  2 +-
 aria/workflows/core/__init__.py                 |  2 +-
 aria/workflows/core/engine.py                   | 11 +++--
 aria/workflows/core/task.py                     |  4 +-
 aria/workflows/executor/celery.py               |  5 +--
 requirements.txt                                |  3 +-
 tests/.pylintrc                                 | 15 +++++++
 tests/mock/context.py                           |  7 +---
 tests/workflows/api/test_task.py                | 18 ++++----
 tests/workflows/api/test_task_graph.py          |  2 +-
 tests/workflows/builtin/__init__.py             | 33 +++++++++++++++
 .../workflows/builtin/test_execute_operation.py | 29 ++-----------
 tests/workflows/builtin/test_heal.py            | 32 ++-------------
 tests/workflows/builtin/test_install.py         | 32 ++-------------
 tests/workflows/builtin/test_uninstall.py       | 32 ++-------------
 tox.ini                                         |  4 +-
 23 files changed, 157 insertions(+), 201 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/.pylintrc
----------------------------------------------------------------------
diff --git a/aria/.pylintrc b/aria/.pylintrc
index ee27fdb..3259c8b 100644
--- a/aria/.pylintrc
+++ b/aria/.pylintrc
@@ -1,3 +1,18 @@
+# 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.
+
 [MASTER]
 
 # Python code to execute, usually for sys.path manipulation such as
@@ -62,7 +77,7 @@ confidence=
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use"--disable=all --enable=classes
 # --disable=W"
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation,import-error
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,redefined-builtin,logging-format-interpolation
 
 [REPORTS]
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/context/workflow.py
----------------------------------------------------------------------
diff --git a/aria/context/workflow.py b/aria/context/workflow.py
index 8e6a2cc..22107ef 100644
--- a/aria/context/workflow.py
+++ b/aria/context/workflow.py
@@ -21,11 +21,16 @@ import threading
 from uuid import uuid4
 from contextlib import contextmanager
 
-from ..logger import LoggerMixin
+from .. import logger
 from ..tools.lru_cache import lru_cache
+from .. import exceptions
 
 
-class WorkflowContext(LoggerMixin):
+class ContextException(exceptions.AriaError):
+    pass
+
+
+class WorkflowContext(logger.LoggerMixin):
     """
     Context object used during workflow creation and execution
     """
@@ -147,8 +152,11 @@ class _CurrentContext(threading.local):
     Provides thread-level context, which sugarcoats the task api.
     """
 
+    def __init__(self):
+        self._workflow_context = None
+
     def _set(self, value):
-        setattr(self, '_workflow_context', value)
+        self._workflow_context = value
 
     def get(self):
         """
@@ -156,29 +164,18 @@ class _CurrentContext(threading.local):
         :return: the workflow context
         :rtype: WorkflowContext
         """
-        try:
-            return getattr(self, '_workflow_context')
-        except AttributeError:
-            return None
-
-    def clear(self):
-        """
-        Clears the current context
-        """
-        if hasattr(self, '_workflow_context'):
-            delattr(self, '_workflow_context')
+        if self._workflow_context is not None:
+            return self._workflow_context
+        raise ContextException("No context was set")
 
     @contextmanager
     def push(self, workflow_context):
         """
-        Switches the current context to the provides context
+        Switches the current context to the provided context
         :param workflow_context: the context to switch to.
         :yields: the current context
         """
-        if hasattr(self, '_workflow_context'):
-            prev_workflow_context = getattr(self, '_workflow_context')
-        else:
-            prev_workflow_context = None
+        prev_workflow_context = self._workflow_context
         self._set(workflow_context)
         try:
             yield self

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/decorators.py
----------------------------------------------------------------------
diff --git a/aria/decorators.py b/aria/decorators.py
index 5713246..a07e2ee 100644
--- a/aria/decorators.py
+++ b/aria/decorators.py
@@ -39,20 +39,20 @@ def workflow(
             suffix_template=suffix_template)
 
     @wraps(func)
-    def _wrapper(ctx, **custom_kwargs):
+    def _wrapper(ctx, **workflow_parameters):
 
         workflow_name = _generate_workflow_name(
             func_name=func.__name__,
             suffix_template=suffix_template,
             ctx=ctx,
-            **custom_kwargs)
+            **workflow_parameters)
 
-        custom_kwargs.setdefault('ctx', ctx)
-        custom_kwargs.setdefault('graph', task_graph.TaskGraph(workflow_name))
-        validate_function_arguments(func, custom_kwargs)
+        workflow_parameters.setdefault('ctx', ctx)
+        workflow_parameters.setdefault('graph', task_graph.TaskGraph(workflow_name))
+        validate_function_arguments(func, workflow_parameters)
         with context.workflow.current.push(ctx):
-            func(**custom_kwargs)
-        return custom_kwargs['graph']
+            func(**workflow_parameters)
+        return workflow_parameters['graph']
     return _wrapper
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/storage/models.py
----------------------------------------------------------------------
diff --git a/aria/storage/models.py b/aria/storage/models.py
index 1b859bd..9aa7cf0 100644
--- a/aria/storage/models.py
+++ b/aria/storage/models.py
@@ -395,7 +395,7 @@ class Task(Model):
     eta = Field(type=datetime, default=datetime.now)
     started_at = Field(type=datetime, default=None)
     ended_at = Field(type=datetime, default=None)
-    max_retries = Field(type=int, default=0)
+    max_retries = Field(type=int, default=1)
     retry_count = Field(type=int, default=0)
 
     # Operation specific fields

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/api/task.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/task.py b/aria/workflows/api/task.py
index a2aea6f..0166991 100644
--- a/aria/workflows/api/task.py
+++ b/aria/workflows/api/task.py
@@ -18,14 +18,27 @@ Provides the tasks to be enterd into the task graph
 """
 from uuid import uuid4
 
-from aria import context
+from ... import context
 
 
 class BaseTask(object):
     """
     Abstract task_graph task
     """
-    pass
+    def __init__(self, ctx=None, **kwargs):
+        if ctx is not None:
+            self._workflow_context = ctx
+        else:
+            self._workflow_context = context.workflow.current.get()
+        self._id = str(uuid4())
+
+    @property
+    def id(self):
+        return self._id
+
+    @property
+    def workflow_context(self):
+        return self._workflow_context
 
 
 class OperationTask(BaseTask):
@@ -45,19 +58,12 @@ class OperationTask(BaseTask):
         :param node_instance: the node instance on which this operation is registered.
         :param inputs: operation inputs.
         """
-        self.id = uuid4()
-        self.workflow_context = context.workflow.current.get()
+        super(OperationTask, self).__init__()
         self.name = name
         self.operation_details = operation_details
         self.node_instance = node_instance
         self.inputs = inputs or {}
 
-    def __getattr__(self, item):
-        try:
-            return self.__getattribute__(item)
-        except AttributeError:
-            return getattr(self._workflow_context.model.task.get(self._task_model.id), item)
-
 
 class WorkflowTask(BaseTask):
     """
@@ -65,11 +71,12 @@ class WorkflowTask(BaseTask):
     """
     def __init__(self, workflow_func, **kwargs):
         """
-        Creates a workflow task using the workflow_func provided and its kwargs
+        Creates a workflow based task using the workflow_func provided, and its kwargs
         :param workflow_func: the function to run
         :param kwargs: the kwargs that would be passed to the workflow_func
         """
-        kwargs.setdefault('ctx', context.workflow.current.get())
+        super(WorkflowTask, self).__init__(**kwargs)
+        kwargs['ctx'] = self.workflow_context
         self._graph = workflow_func(**kwargs)
 
     @property
@@ -82,17 +89,13 @@ class WorkflowTask(BaseTask):
 
     def __getattr__(self, item):
         try:
-            return self.__getattribute__(item)
+            return getattr(self._graph, item)
         except AttributeError:
-            try:
-                return getattr(self._graph, item)
-            except AttributeError:
-                return getattr(context.workflow.current.get(), item)
+            return super(WorkflowTask, self).__getattribute__(item)
 
 
-class StubTask(WorkflowTask):
+class StubTask(BaseTask):
     """
     Enables creating empty tasks.
     """
-    def __init__(self):
-        super(StubTask, self).__init__(lambda **kwargs: None)
+    pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/api/task_graph.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/task_graph.py b/aria/workflows/api/task_graph.py
index 067ad2b..634a6e2 100644
--- a/aria/workflows/api/task_graph.py
+++ b/aria/workflows/api/task_graph.py
@@ -268,12 +268,11 @@ class TaskGraph(object):
         if isinstance(dependent, Iterable):
             for dependent_task in dependent:
                 self.remove_dependency(dependent_task, dependency)
+        elif isinstance(dependency, Iterable):
+            for dependency_task in dependency:
+                self.remove_dependency(dependent, dependency_task)
         else:
-            if isinstance(dependency, Iterable):
-                for dependency_task in dependency:
-                    self.remove_dependency(dependent, dependency_task)
-            else:
-                self._graph.remove_edge(dependent.id, dependency.id)
+            self._graph.remove_edge(dependent.id, dependency.id)
 
         return True
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/builtin/heal.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/heal.py b/aria/workflows/builtin/heal.py
index 8f2ecb7..dc320dc 100644
--- a/aria/workflows/builtin/heal.py
+++ b/aria/workflows/builtin/heal.py
@@ -52,9 +52,7 @@ def heal(ctx, graph, node_instance_id):
         failing_node_instances=failed_node_instance_subgraph,
         targeted_node_instances=targeted_node_instances)
 
-    graph.add_tasks(uninstall_subgraph)
-    graph.add_tasks(install_subgraph)
-    graph.add_dependency(install_subgraph, uninstall_subgraph)
+    graph.sequence(uninstall_subgraph, install_subgraph)
 
 
 @workflow(suffix_template='{failing_node_instances}')
@@ -76,9 +74,6 @@ def heal_uninstall(ctx, graph, failing_node_instances, targeted_node_instances):
         node_instance_sub_workflows[node_instance.id] = node_instance_stub
         graph.add_tasks(node_instance_stub)
 
-    # Create install sub workflow for each failing node on the same graph
-    node_instance_sub_workflows = node_instance_sub_workflows or {}
-
     # create install sub workflow for every node instance
     for node_instance in failing_node_instances:
         node_instance_sub_workflow = task.WorkflowTask(uninstall_node_instance,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/builtin/workflows.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/workflows.py b/aria/workflows/builtin/workflows.py
index 4bff7cd..fc54f75 100644
--- a/aria/workflows/builtin/workflows.py
+++ b/aria/workflows/builtin/workflows.py
@@ -218,7 +218,7 @@ def relationships_tasks(graph,
                 index=index)
             sub_tasks.append(relationship_operations)
 
-    return graph.sequence(*sub_tasks) if sub_tasks else sub_tasks
+    return graph.sequence(*sub_tasks)
 
 
 def relationship_tasks(graph,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/core/__init__.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/__init__.py b/aria/workflows/core/__init__.py
index d950350..646f44a 100644
--- a/aria/workflows/core/__init__.py
+++ b/aria/workflows/core/__init__.py
@@ -17,4 +17,4 @@
 Core for the workflow execution mechanism
 """
 
-from . import translation, task
+from . import task

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/core/engine.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/engine.py b/aria/workflows/core/engine.py
index e9b61c4..60400e6 100644
--- a/aria/workflows/core/engine.py
+++ b/aria/workflows/core/engine.py
@@ -22,12 +22,11 @@ from datetime import datetime
 
 import networkx
 
-from aria import events, logger
-from aria.storage import models
-
-from .. import exceptions
 from . import translation
-from .task import BaseWorkflowTask
+from . import task as engine_task
+from .. import exceptions
+from ...storage import models
+from ... import events, logger
 
 
 class Engine(logger.LoggerMixin):
@@ -83,7 +82,7 @@ class Engine(logger.LoggerMixin):
         return (data['task'] for _, data in self._execution_graph.nodes_iter(data=True))
 
     def _handle_executable_task(self, task):
-        if isinstance(task, BaseWorkflowTask):
+        if isinstance(task, engine_task.BaseWorkflowTask):
             task.status = models.Task.SUCCESS
         else:
             events.sent_task_signal.send(task)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/core/task.py
----------------------------------------------------------------------
diff --git a/aria/workflows/core/task.py b/aria/workflows/core/task.py
index 6a19aa6..9123714 100644
--- a/aria/workflows/core/task.py
+++ b/aria/workflows/core/task.py
@@ -19,8 +19,8 @@ Workflow tasks
 
 from datetime import datetime
 
-from aria import logger
-from aria.storage import models
+from ... import logger
+from ...storage import models
 
 
 class BaseTask(logger.LoggerMixin):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/aria/workflows/executor/celery.py
----------------------------------------------------------------------
diff --git a/aria/workflows/executor/celery.py b/aria/workflows/executor/celery.py
index 2d486f2..a82a6b7 100644
--- a/aria/workflows/executor/celery.py
+++ b/aria/workflows/executor/celery.py
@@ -43,11 +43,10 @@ class CeleryExecutor(BaseExecutor):
         self._started_queue.get(timeout=30)
 
     def execute(self, task):
-        operation_context = task.context
         self._tasks[task.id] = task
         self._results[task.id] = self._app.send_task(
-            operation_context.operation_details['operation'],
-            kwargs=operation_context.inputs,
+            task.operation_details['operation'],
+            kwargs=task.inputs,
             task_id=task.id,
             queue=self._get_queue(task))
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/requirements.txt
----------------------------------------------------------------------
diff --git a/requirements.txt b/requirements.txt
index 44d72b6..45eb5a5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,10 +11,9 @@
 # limitations under the License.
 
 PyYAML==3.10
-billiard==3.3.0.20
 networkx==1.9
 requests==2.7.0
 retrying==1.3.3
 blinker==1.4
-ordereddict==1.1     # This should be moved to setup.py and implement logic concerning 2.7/2.6
+ordereddict==1.1 ; python_version < '2.7'
 jsonpickle

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/.pylintrc
----------------------------------------------------------------------
diff --git a/tests/.pylintrc b/tests/.pylintrc
index 8648eff..c455d8a 100644
--- a/tests/.pylintrc
+++ b/tests/.pylintrc
@@ -1,3 +1,18 @@
+# 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.
+
 [MASTER]
 
 # Python code to execute, usually for sys.path manipulation such as

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/mock/context.py
----------------------------------------------------------------------
diff --git a/tests/mock/context.py b/tests/mock/context.py
index 66228df..a89612e 100644
--- a/tests/mock/context.py
+++ b/tests/mock/context.py
@@ -15,16 +15,11 @@
 
 from aria import context, application_model_storage
 
-from ..storage import InMemoryModelDriver
 from . import models
+from ..storage import InMemoryModelDriver
 
 
 def simple():
-    """
-    Create the following graph in storage:
-    dependency_node <------ dependent_node
-    :return:
-    """
     storage = application_model_storage(InMemoryModelDriver())
     storage.setup()
     return context.workflow.WorkflowContext(

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/api/test_task.py
----------------------------------------------------------------------
diff --git a/tests/workflows/api/test_task.py b/tests/workflows/api/test_task.py
index 3a15887..7119529 100644
--- a/tests/workflows/api/test_task.py
+++ b/tests/workflows/api/test_task.py
@@ -24,6 +24,11 @@ from ... 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(
@@ -81,16 +86,13 @@ class TestWorkflowTask(object):
 
         workspace = {}
 
+        mock_class = type('mock_class', (object,), {'test_attribute': True})
+
         def sub_workflow(**kwargs):
             workspace.update(kwargs)
-            return True
+            return mock_class
 
         with context.workflow.current.push(ctx):
             workflow_task = api.task.WorkflowTask(sub_workflow, kwarg='workflow_kwarg')
-            assert workflow_task.blueprint_id == ctx.blueprint_id
-            assert workflow_task.deployment == ctx.deployment
-            assert list(workflow_task.nodes) == list(ctx.nodes)
-            assert list(workflow_task.node_instances) == list(ctx.node_instances)
-            assert workflow_task.execution == ctx.execution
-            assert workspace == {'kwarg': 'workflow_kwarg', 'ctx': ctx}
-            assert workflow_task.graph is True
+            assert workflow_task.graph is mock_class
+            assert workflow_task.test_attribute is True

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/api/test_task_graph.py
----------------------------------------------------------------------
diff --git a/tests/workflows/api/test_task_graph.py b/tests/workflows/api/test_task_graph.py
index 7d409cf..7ff3d68 100644
--- a/tests/workflows/api/test_task_graph.py
+++ b/tests/workflows/api/test_task_graph.py
@@ -22,7 +22,7 @@ from aria.workflows.api import task_graph, task
 
 class MockTask(task.BaseTask):
     def __init__(self):
-        self.id = str(uuid4())
+        super(MockTask, self).__init__(ctx={})
 
 
 @pytest.fixture

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/builtin/__init__.py
----------------------------------------------------------------------
diff --git a/tests/workflows/builtin/__init__.py b/tests/workflows/builtin/__init__.py
index 6d58900..56fbcc8 100644
--- a/tests/workflows/builtin/__init__.py
+++ b/tests/workflows/builtin/__init__.py
@@ -51,3 +51,36 @@ def assert_node_uninstall_operations(operations, with_relationships=False):
     else:
         for i, operation in enumerate(operations):
             assert operation.name.startswith(mock.operations.NODE_OPERATIONS_UNINSTALL[i])
+
+
+def ctx_with_basic_graph():
+    """
+    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)
+
+    return simple_context
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/builtin/test_execute_operation.py
----------------------------------------------------------------------
diff --git a/tests/workflows/builtin/test_execute_operation.py b/tests/workflows/builtin/test_execute_operation.py
index 82010c8..9409686 100644
--- a/tests/workflows/builtin/test_execute_operation.py
+++ b/tests/workflows/builtin/test_execute_operation.py
@@ -19,35 +19,12 @@ from aria.workflows.api import task
 from aria.workflows.builtin.execute_operation import execute_operation
 
 from ... import mock
+from . import ctx_with_basic_graph
 
 
-@pytest.fixture()
+@pytest.fixture
 def ctx():
-    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)
-
-    return simple_context
+    return ctx_with_basic_graph()
 
 
 def test_execute_operation(ctx):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/builtin/test_heal.py
----------------------------------------------------------------------
diff --git a/tests/workflows/builtin/test_heal.py b/tests/workflows/builtin/test_heal.py
index c62a063..edffe2c 100644
--- a/tests/workflows/builtin/test_heal.py
+++ b/tests/workflows/builtin/test_heal.py
@@ -19,37 +19,13 @@ from aria.workflows.api import task
 from aria.workflows.builtin.heal import heal
 
 from . import (assert_node_install_operations,
-               assert_node_uninstall_operations)
-from ... import mock
+               assert_node_uninstall_operations,
+               ctx_with_basic_graph)
 
 
-@pytest.fixture()
+@pytest.fixture
 def ctx():
-    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)
-
-    return simple_context
+    return ctx_with_basic_graph()
 
 
 def test_heal_dependent_node(ctx):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/builtin/test_install.py
----------------------------------------------------------------------
diff --git a/tests/workflows/builtin/test_install.py b/tests/workflows/builtin/test_install.py
index d27ece4..29212e3 100644
--- a/tests/workflows/builtin/test_install.py
+++ b/tests/workflows/builtin/test_install.py
@@ -18,37 +18,13 @@ import pytest
 from aria.workflows.builtin.install import install
 from aria.workflows.api import task
 
-from . import assert_node_install_operations
-from ... import mock
+from . import (assert_node_install_operations,
+               ctx_with_basic_graph)
 
 
-@pytest.fixture()
+@pytest.fixture
 def ctx():
-    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)
-
-    return simple_context
+    return ctx_with_basic_graph()
 
 
 def test_install(ctx):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tests/workflows/builtin/test_uninstall.py
----------------------------------------------------------------------
diff --git a/tests/workflows/builtin/test_uninstall.py b/tests/workflows/builtin/test_uninstall.py
index cee7998..2d00673 100644
--- a/tests/workflows/builtin/test_uninstall.py
+++ b/tests/workflows/builtin/test_uninstall.py
@@ -18,37 +18,13 @@ import pytest
 from aria.workflows.api import task
 from aria.workflows.builtin.uninstall import uninstall
 
-from . import assert_node_uninstall_operations
-from ... import mock
+from . import (assert_node_uninstall_operations,
+               ctx_with_basic_graph)
 
 
-@pytest.fixture()
+@pytest.fixture
 def ctx():
-    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)
-
-    return simple_context
+    return ctx_with_basic_graph()
 
 
 def test_uninstall(ctx):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/45da7263/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index fb6283d..8432c85 100644
--- a/tox.ini
+++ b/tox.ini
@@ -30,7 +30,7 @@ commands=pytest tests --cov-report term-missing --cov aria
 commands=pytest tests --cov-report term-missing --cov aria
 
 [testenv:pylint_code]
-commands=pylint --rcfile=aria/.pylintrc --disable=print-statement --ignore=commands.py aria
+commands=pylint --rcfile=aria/.pylintrc --disable=fixme --ignore=commands.py aria
 
 [testenv:pylint_tests]
-commands=pylint --rcfile=tests/.pylintrc --disable=print-statement tests
+commands=pylint --rcfile=tests/.pylintrc --disable=fixme tests


Mime
View raw message