Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-262-Inconsistent-node-attributes-behavior 558e162a9 -> a48f8158d (forced update)
tiny fix for several instrumenetation fields Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/a48f8158 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a48f8158 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a48f8158 Branch: refs/heads/ARIA-262-Inconsistent-node-attributes-behavior Commit: a48f8158d4f21d11c53641191c32dfa079314704 Parents: bd7a438 Author: max-orlov <[email protected]> Authored: Thu Jun 1 17:30:39 2017 +0300 Committer: max-orlov <[email protected]> Committed: Thu Jun 1 17:43:55 2017 +0300 ---------------------------------------------------------------------- aria/storage/collection_instrumentation.py | 21 +++++++++++++-------- aria/utils/imports.py | 2 +- tests/orchestrator/context/test_operation.py | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a48f8158/aria/storage/collection_instrumentation.py ---------------------------------------------------------------------- diff --git a/aria/storage/collection_instrumentation.py b/aria/storage/collection_instrumentation.py index 792f76c..680103e 100644 --- a/aria/storage/collection_instrumentation.py +++ b/aria/storage/collection_instrumentation.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from aria.modeling import models +from ..modeling import models +from . import exceptions class _InstrumentedCollection(object): @@ -110,7 +111,8 @@ class _InstrumentedCollection(object): if self._is_top_level: # We are at the top level field = getattr(self._parent, self._field_name) - self._set_field(field, key, value if key in field else self._encapsulate_value(key, value)) + self._set_field( + field, key, value if key in field else self._encapsulate_value(key, value)) self._mapi.update(self._parent) else: # We are not at the top level @@ -201,7 +203,7 @@ class _InstrumentedModel(object): def __init__(self, original_model, mapi, instrumentation): """ - The original model + The original model :param original_model: the model to be instrumented :param mapi: the mapi for that model """ @@ -209,7 +211,7 @@ class _InstrumentedModel(object): self._original_model = original_model self._mapi = mapi self._instrumentation = instrumentation - self._instrumentation_cls = self._apply_instrumentation() + self._apply_instrumentation() def __getattr__(self, item): return_value = getattr(self._original_model, item) @@ -232,14 +234,18 @@ class _InstrumentedModel(object): instrumentation_cls = _InstrumentedList else: # TODO: raise proper error - raise + raise exceptions.StorageError( + "ARIA supports instrumentation for dict and list. Field {field} of the " + "class {model} is of {type} type.".format( + field=field, + model=self._original_model, + type=type(field))) instrumented_class = instrumentation_cls(seq=field, parent=self._original_model, mapi=self._mapi, field_name=field_name) setattr(self, field_name, instrumented_class) - return instrumentation_cls class _WrappedModel(object): @@ -247,7 +253,7 @@ class _WrappedModel(object): def __init__(self, wrapped, instrumentation, **kwargs): """ - :param instrumented_cls: The class to be instrumented + :param instrumented_cls: The class to be instrumented :param instrumentation_cls: the instrumentation cls :param wrapped: the currently wrapped instance :param kwargs: and kwargs to te passed to the instrumented class. @@ -279,4 +285,3 @@ def instrument(instrumentation, original_model, mapi): return _InstrumentedModel(original_model, mapi, instrumentation) return _WrappedModel(original_model, instrumentation, mapi=mapi) - http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a48f8158/aria/utils/imports.py ---------------------------------------------------------------------- diff --git a/aria/utils/imports.py b/aria/utils/imports.py index 64a48cf..35aa0fc 100644 --- a/aria/utils/imports.py +++ b/aria/utils/imports.py @@ -17,8 +17,8 @@ Utility methods for dynamically loading python code """ -import importlib import pkgutil +import importlib def import_fullname(name, paths=None): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a48f8158/tests/orchestrator/context/test_operation.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py index c50f2e3..59df059 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, {}), - # (process.ProcessExecutor, {'python_path': [tests.ROOT_DIR]}), + (process.ProcessExecutor, {'python_path': [tests.ROOT_DIR]}), ]) def executor(request): executor_cls, executor_kwargs = request.param
