Repository: incubator-ariatosca
Updated Branches:
  refs/heads/runtime_props_to_attr de86fb8c6 -> 1c7347e6d (forced update)


fixed some tests


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

Branch: refs/heads/runtime_props_to_attr
Commit: 1c7347e6d6a6d752faf896743f2375276759f338
Parents: 87dad55
Author: max-orlov <ma...@gigaspaces.com>
Authored: Mon May 15 12:26:35 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Mon May 15 13:10:37 2017 +0300

----------------------------------------------------------------------
 aria/orchestrator/context/operation.py       |  6 +++---
 aria/storage/instrumentation.py              | 25 ++++++++++++-----------
 tests/orchestrator/context/test_operation.py | 14 +++++++------
 3 files changed, 24 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1c7347e6/aria/orchestrator/context/operation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/operation.py 
b/aria/orchestrator/context/operation.py
index 2c3f173..2182db5 100644
--- a/aria/orchestrator/context/operation.py
+++ b/aria/orchestrator/context/operation.py
@@ -80,9 +80,9 @@ class _DecorateAttributes(object):
 
     def __call__(self, *args, **kwargs):
         func_self = args[0]
-        actor = self._func(*args, **kwargs)
-        model = func_self.model
-        self.attributes = self._Attributes(model, actor)
+        self._actor = self._func(*args, **kwargs)
+        self._model = func_self.model
+        self.attributes = self._Attributes(self._model, self._actor)
         return self
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1c7347e6/aria/storage/instrumentation.py
----------------------------------------------------------------------
diff --git a/aria/storage/instrumentation.py b/aria/storage/instrumentation.py
index 701c058..a11bb28 100644
--- a/aria/storage/instrumentation.py
+++ b/aria/storage/instrumentation.py
@@ -148,12 +148,12 @@ class _Instrumentation(object):
         def listener(target, value, initiator):
             tracked_instances = 
self.tracked_changes.setdefault(target.__modelname__, {})
             tracked_attributes = tracked_instances.setdefault(target.id, {})
-            collection = tracked_attributes.setdefault(initiator.key, [])
+            collection_attr = tracked_attributes.setdefault(initiator.key, [])
             instance_as_dict = value.to_dict()
             instance_as_dict.update((k, getattr(value, k))
                                     for k in getattr(value, 
'__private_fields__', []))
             instance_as_dict['_MODEL_CLS'] = value.__modelname__
-            collection.append(instance_as_dict)
+            collection_attr.append(instance_as_dict)
 
         listener_args = (collection_attr, 'append', listener)
         sqlalchemy.event.listen(*listener_args)
@@ -254,21 +254,22 @@ def apply_tracked_changes(tracked_changes, new_instances, 
model):
     """
     successfully_updated_changes = dict()
     try:
+
+        # Handle new instances
+        for mapi_name, new_instance in new_instances.items():
+            successfully_updated_changes[mapi_name] = dict()
+            mapi = getattr(model, mapi_name)
+            for tmp_id, new_instance_kwargs in new_instance.items():
+                instance = mapi.model_cls(**new_instance_kwargs)
+                mapi.put(instance)
+                successfully_updated_changes[mapi_name][instance.id] = 
new_instance_kwargs
+                new_instance[tmp_id] = instance
+
         # handle instance updates
         for mapi_name, tracked_instances in tracked_changes.items():
             successfully_updated_changes[mapi_name] = dict()
             mapi = getattr(model, mapi_name)
 
-            # Handle new instances
-            for mapi_name, new_instance in new_instances.items():
-                successfully_updated_changes[mapi_name] = dict()
-                mapi = getattr(model, mapi_name)
-                for tmp_id, new_instance_kwargs in new_instance.items():
-                    instance = mapi.model_cls(**new_instance_kwargs)
-                    mapi.put(instance)
-                    successfully_updated_changes[mapi_name][instance.id] = 
new_instance_kwargs
-                    new_instance[tmp_id] = instance
-
             for instance_id, tracked_attributes in tracked_instances.items():
                 successfully_updated_changes[mapi_name][instance_id] = dict()
                 instance = None

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1c7347e6/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py 
b/tests/orchestrator/context/test_operation.py
index 14868e8..6802593 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -263,7 +263,7 @@ def test_plugin_workdir(ctx, thread_executor, tmpdir):
 
 
 @pytest.fixture(params=[
-    # (thread.ThreadExecutor, {}),
+    (thread.ThreadExecutor, {}),
     (process.ProcessExecutor, {'python_path': [tests.ROOT_DIR]}),
 ])
 def executor(request):
@@ -345,7 +345,7 @@ def test_relationship_operation_logging(ctx, executor):
 
 def test_attribute_consumption(ctx, executor, dataholder):
     # region Updating node operation
-    node_int_name, node_op_name = mock.operations.NODE_OPERATIONS_INSTALL[0]   
 # Standard.install
+    node_int_name, node_op_name = mock.operations.NODE_OPERATIONS_INSTALL[0]
 
     source_node = ctx.model.node.get_by_name(mock.models.DEPENDENT_NODE_NAME)
 
@@ -363,7 +363,7 @@ def test_attribute_consumption(ctx, executor, dataholder):
     # endregion
 
     # region updating relationship operation
-    rel_int_name, rel_op_name = 
mock.operations.RELATIONSHIP_OPERATIONS_INSTALL[2]  # Configure.add_source
+    rel_int_name, rel_op_name = 
mock.operations.RELATIONSHIP_OPERATIONS_INSTALL[2]
 
     relationship = ctx.model.relationship.list()[0]
     interface = mock.models.create_interface(
@@ -400,7 +400,9 @@ def test_attribute_consumption(ctx, executor, dataholder):
 
     assert len(source_node.attributes) == len(target_node.attributes) == 1
     assert source_node.attributes['key'] != target_node.attributes['key']
-    assert source_node.attributes['key'].value == 
target_node.attributes['key'].value == dataholder['key']
+    assert source_node.attributes['key'].value == \
+           target_node.attributes['key'].value == \
+           dataholder['key']
 
 
 def _assert_loggins(ctx, inputs):
@@ -437,10 +439,10 @@ def _assert_loggins(ctx, inputs):
 
 @operation
 def logged_operation(ctx, **_):
-    ctx.logger.info(ctx.task.inputs['op_start'])
+    ctx.logger.info(ctx.task.inputs['op_start'].value)
     # enables to check the relation between the created_at field properly
     time.sleep(1)
-    ctx.logger.debug(ctx.task.inputs['op_end'])
+    ctx.logger.debug(ctx.task.inputs['op_end'].value)
 
 
 @operation

Reply via email to