Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-42-Generic-ctx-serialization-mechanism 7ef512da6 -> 34369879c


review 2 fixups


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

Branch: refs/heads/ARIA-42-Generic-ctx-serialization-mechanism
Commit: 34369879c467b621d0321c91b0ccefb2f33d94dc
Parents: 7ef512d
Author: mxmrlv <[email protected]>
Authored: Wed Feb 8 21:33:12 2017 +0200
Committer: mxmrlv <[email protected]>
Committed: Wed Feb 8 21:33:12 2017 +0200

----------------------------------------------------------------------
 aria/storage/core.py                                   | 11 +++++++++++
 aria/storage/sql_mapi.py                               | 10 ++++++++++
 tests/orchestrator/workflows/executor/test_executor.py | 13 ++++++++++---
 .../workflows/executor/test_process_executor.py        | 13 ++++++++++---
 4 files changed, 41 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/34369879/aria/storage/core.py
----------------------------------------------------------------------
diff --git a/aria/storage/core.py b/aria/storage/core.py
index aa9e1a9..6ed4e72 100644
--- a/aria/storage/core.py
+++ b/aria/storage/core.py
@@ -62,6 +62,17 @@ class Storage(LoggerMixin):
                  initiator=None,
                  initiator_kwargs=None,
                  **kwargs):
+        """
+
+        :param api_cls: API cls for each model.
+        :param api_kwargs: 
+        :param items: the items to register
+        :param initiator: a func which initializes the storage before the 
first use.
+        This function should return a dict, this dict would be passed in 
addition to the api kwargs.
+        This enables the creation of any unpickable objects across process.
+        :param initiator_kwargs:
+        :param kwargs:
+        """
         super(Storage, self).__init__(**kwargs)
         self.api = api_cls
         self.registered = {}

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/34369879/aria/storage/sql_mapi.py
----------------------------------------------------------------------
diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py
index c9a29ea..9dae08a 100644
--- a/aria/storage/sql_mapi.py
+++ b/aria/storage/sql_mapi.py
@@ -371,6 +371,16 @@ class SQLAlchemyModelAPI(api.ModelAPI):
 
 
 def init_storage(base_dir, filename='db.sqlite'):
+    """
+    A builtin ModelStorage initiator.
+    Creates a sqlalchemy engine and a session to be passed to the mapi.
+
+    Initiator_kwargs must be passed to the ModelStorage which must hold the 
base_dir for the
+    location of the db file, and an option filename. This would create an 
sqlite db.
+    :param base_dir: the dir of the db
+    :param filename: the db file name.
+    :return:
+    """
     uri = 'sqlite:///{platform_char}{path}'.format(
         # Handles the windows behavior where there is not root, but drivers.
         # Thus behaving as relative path.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/34369879/tests/orchestrator/workflows/executor/test_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_executor.py 
b/tests/orchestrator/workflows/executor/test_executor.py
index 0b33ae6..1550f28 100644
--- a/tests/orchestrator/workflows/executor/test_executor.py
+++ b/tests/orchestrator/workflows/executor/test_executor.py
@@ -81,13 +81,20 @@ class MockException(Exception):
     pass
 
 
-class MockContext(operation.BaseOperationContext):
+class MockContext(object):
 
-    def __init__(self, *args, **kwargs):                                       
                     # pylint: disable=super-init-not-called
+    def __init__(self, *args, **kwargs):
         pass
 
     def __getattr__(self, item):
-        return None
+        if item == 'serialization_dict':
+            return {'context_cls': self.__class__, 'context': {}}
+        else:
+            return None
+
+    @staticmethod
+    def deserialize_from_dict(**kwargs):
+        return MockContext()
 
 
 class MockTask(object):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/34369879/tests/orchestrator/workflows/executor/test_process_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py 
b/tests/orchestrator/workflows/executor/test_process_executor.py
index 9f0d1db..3f437ed 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -112,13 +112,20 @@ def mock_plugin(plugin_manager, tmpdir):
     return plugin_manager.install(source=plugin_path)
 
 
-class MockContext(operation.BaseOperationContext):
+class MockContext(object):
 
-    def __init__(self, *args, **kwargs):                                       
                     # pylint: disable=super-init-not-called
+    def __init__(self, *args, **kwargs):
         pass
 
     def __getattr__(self, item):
-        return None
+        if item == 'serialization_dict':
+            return {'context_cls': self.__class__, 'context': {}}
+        else:
+            return None
+
+    @staticmethod
+    def deserialize_from_dict(**kwargs):
+        return MockContext()
 
 
 class MockTask(object):

Reply via email to