You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mx...@apache.org on 2017/06/01 15:10:30 UTC
incubator-ariatosca git commit: added try/finally and fixes some tests
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-262-Inconsistent-node-attributes-behavior a48f8158d -> 1a4066524
added try/finally and fixes 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/1a406652
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1a406652
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1a406652
Branch: refs/heads/ARIA-262-Inconsistent-node-attributes-behavior
Commit: 1a40665243f35dfaaf8f8350ca335ad7bc253f9c
Parents: a48f815
Author: max-orlov <ma...@gigaspaces.com>
Authored: Thu Jun 1 18:10:25 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Thu Jun 1 18:10:25 2017 +0300
----------------------------------------------------------------------
aria/storage/core.py | 10 ++++++----
.../context/test_collection_instrumentation.py | 14 +++++++++-----
2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1a406652/aria/storage/core.py
----------------------------------------------------------------------
diff --git a/aria/storage/core.py b/aria/storage/core.py
index 65ca8e7..b752505 100644
--- a/aria/storage/core.py
+++ b/aria/storage/core.py
@@ -170,7 +170,6 @@ class ModelStorage(Storage):
@contextmanager
def instrument(self, instrumentation):
- original_instrumentation = {}
def _instrument(source_inst, target_inst=None):
for mapi in self.registered.values():
@@ -182,6 +181,9 @@ class ModelStorage(Storage):
else:
del mapi._instrumentation[cls]
- _instrument(instrumentation, original_instrumentation)
- yield self
- _instrument(original_instrumentation)
+ original_instrumentation = {}
+ try:
+ _instrument(instrumentation, original_instrumentation)
+ yield self
+ finally:
+ _instrument(original_instrumentation)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1a406652/tests/orchestrator/context/test_collection_instrumentation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_collection_instrumentation.py b/tests/orchestrator/context/test_collection_instrumentation.py
index b8b3295..066cc33 100644
--- a/tests/orchestrator/context/test_collection_instrumentation.py
+++ b/tests/orchestrator/context/test_collection_instrumentation.py
@@ -25,12 +25,16 @@ class MockActor(object):
self.list_ = []
-class MockModel(object):
+class MockMAPI(object):
def __init__(self):
- self.parameter = type('MockModel', (object, ), {'model_cls': Parameter,
- 'put': lambda *args, **kwargs: None,
- 'update': lambda *args, **kwargs: None})()
+ pass
+
+ def put(self, *args, **kwargs):
+ pass
+
+ def update(self, *args, **kwargs):
+ pass
class CollectionInstrumentation(object):
@@ -41,7 +45,7 @@ class CollectionInstrumentation(object):
@pytest.fixture
def model(self):
- return MockModel()
+ return MockMAPI()
@pytest.fixture
def dict_(self, actor, model):