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: review3
Date Tue, 15 Nov 2016 15:07:57 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-9-API-for-operation-context ef1516464 -> c4091b165


review3


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

Branch: refs/heads/ARIA-9-API-for-operation-context
Commit: c4091b1653307053f9c9d728fd73cbe079a5ce5c
Parents: ef15164
Author: mxmrlv <mxmrlv@gmail.com>
Authored: Tue Nov 15 17:07:48 2016 +0200
Committer: mxmrlv <mxmrlv@gmail.com>
Committed: Tue Nov 15 17:07:48 2016 +0200

----------------------------------------------------------------------
 aria/storage/drivers.py                |  6 ++++--
 aria/workflows/api/task.py             | 14 +++++++-------
 aria/workflows/builtin/workflows.py    |  8 ++++----
 tests/context/test_operation.py        |  4 ++--
 tests/context/test_toolbelt.py         |  4 ++--
 tests/storage/test_resource_storage.py | 12 ++++++++++++
 tests/workflows/api/test_task.py       |  4 ++--
 7 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/aria/storage/drivers.py
----------------------------------------------------------------------
diff --git a/aria/storage/drivers.py b/aria/storage/drivers.py
index ad9aff3..d20a7ce 100644
--- a/aria/storage/drivers.py
+++ b/aria/storage/drivers.py
@@ -371,7 +371,8 @@ class FileSystemResourceDriver(ResourceDriver, BaseFileSystemDriver):
         """
         resource = os.path.join(self.directory, entry_type, entry_id, path or '')
         if not os.path.exists(resource):
-            raise StorageError("Resource does not exist")
+            raise StorageError("Resource {0} does not exist"
+                               .format(os.path.join(entry_type, entry_id, path)))
         if not os.path.isfile(resource):
             resources = os.listdir(resource)
             if len(resources) != 1:
@@ -391,7 +392,8 @@ class FileSystemResourceDriver(ResourceDriver, BaseFileSystemDriver):
         """
         resource = os.path.join(self.directory, entry_type, entry_id, path or '')
         if not os.path.exists(resource):
-            raise StorageError("Resource does not exist")
+            raise StorageError("Resource {0} does not exist"
+                               .format(os.path.join(entry_type, entry_id, path)))
         if os.path.isfile(resource):
             shutil.copy2(resource, destination)
         else:

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/aria/workflows/api/task.py
----------------------------------------------------------------------
diff --git a/aria/workflows/api/task.py b/aria/workflows/api/task.py
index 3903dfc..f6bf996 100644
--- a/aria/workflows/api/task.py
+++ b/aria/workflows/api/task.py
@@ -110,26 +110,26 @@ class OperationTask(BaseTask):
                    **kwargs)
 
     @classmethod
-    def relationship_instance(cls, instance, actor, operation_end, inputs=None, *args, **kwargs):
+    def relationship_instance(cls, instance, name, operation_end, inputs=None, *args, **kwargs):
         """
         Represents a relationship based operation
 
-        :param actor: the node of which this operation belongs to.
-        :param instance: the name of the operation.
+        :param instance: the relationship of which this operation belongs to.
+        :param name: the name of the operation.
         :param operation_end: source or target end of the relationship, this corresponds
directly
         with 'source_operations' and 'target_operations'
         :param inputs any additional inputs to the operation
         """
-        assert isinstance(actor, storage.models.RelationshipInstance)
+        assert isinstance(instance, storage.models.RelationshipInstance)
         if operation_end not in [cls.TARGET_OPERATION, cls.SOURCE_OPERATION]:
             raise exceptions.TaskException('The operation end should be {0} or {1}'.format(
                 cls.TARGET_OPERATION, cls.SOURCE_OPERATION
             ))
-        operation_details = getattr(actor.relationship, operation_end)[instance]
+        operation_details = getattr(instance.relationship, operation_end)[name]
         operation_inputs = operation_details.get('inputs', {})
         operation_inputs.update(inputs or {})
-        return cls(actor=actor,
-                   name=instance,
+        return cls(actor=instance,
+                   name=name,
                    operation_mapping=operation_details.get('operation'),
                    inputs=operation_inputs,
                    *args,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/aria/workflows/builtin/workflows.py
----------------------------------------------------------------------
diff --git a/aria/workflows/builtin/workflows.py b/aria/workflows/builtin/workflows.py
index 494dc4f..0eb8c34 100644
--- a/aria/workflows/builtin/workflows.py
+++ b/aria/workflows/builtin/workflows.py
@@ -204,12 +204,12 @@ def relationship_tasks(relationship_instance, operation_name):
     :return:
     """
     source_operation = task.OperationTask.relationship_instance(
-        actor=relationship_instance,
-        instance=operation_name,
+        instance=relationship_instance,
+        name=operation_name,
         operation_end=task.OperationTask.SOURCE_OPERATION)
     target_operation = task.OperationTask.relationship_instance(
-        actor=relationship_instance,
-        instance=operation_name,
+        instance=relationship_instance,
+        name=operation_name,
         operation_end=task.OperationTask.TARGET_OPERATION)
 
     return source_operation, target_operation

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/tests/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/context/test_operation.py b/tests/context/test_operation.py
index ac5f15f..0c34a0f 100644
--- a/tests/context/test_operation.py
+++ b/tests/context/test_operation.py
@@ -117,8 +117,8 @@ def test_relationship_operation_task_execution(ctx, executor):
     def basic_workflow(graph, **_):
         graph.add_tasks(
             api.task.OperationTask.relationship_instance(
-                actor=relationship_instance,
-                instance=operation_name,
+                instance=relationship_instance,
+                name=operation_name,
                 operation_end=api.task.OperationTask.SOURCE_OPERATION,
                 inputs=inputs
             )

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/tests/context/test_toolbelt.py
----------------------------------------------------------------------
diff --git a/tests/context/test_toolbelt.py b/tests/context/test_toolbelt.py
index 57a698e..4288ce9 100644
--- a/tests/context/test_toolbelt.py
+++ b/tests/context/test_toolbelt.py
@@ -134,8 +134,8 @@ def test_relationship_tool_belt(workflow_context, executor):
     def basic_workflow(graph, **_):
         graph.add_tasks(
             api.task.OperationTask.relationship_instance(
-                actor=relationship_instance,
-                instance=operation_name,
+                instance=relationship_instance,
+                name=operation_name,
                 operation_end=api.task.OperationTask.SOURCE_OPERATION,
                 inputs=inputs
             )

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/tests/storage/test_resource_storage.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_resource_storage.py b/tests/storage/test_resource_storage.py
index c9ecd69..9673a26 100644
--- a/tests/storage/test_resource_storage.py
+++ b/tests/storage/test_resource_storage.py
@@ -89,6 +89,18 @@ class TestResourceStorage(TestFileSystem):
         with open(os.path.join(self.path, os.path.join(temp_dir, tmpfile_name))) as f:
             assert f.read() == 'fake context'
 
+    def test_download_non_existing_file(self):
+        storage = ResourceStorage(FileSystemResourceDriver(directory=self.path))
+        self._create(storage)
+        with pytest.raises(StorageError):
+            storage.blueprint.download(entry_id='blueprint_id', destination='', path='fake_path')
+
+    def test_data_non_existing_file(self):
+        storage = ResourceStorage(FileSystemResourceDriver(directory=self.path))
+        self._create(storage)
+        with pytest.raises(StorageError):
+            storage.blueprint.data(entry_id='blueprint_id', path='fake_path')
+
     def test_data_file(self):
         storage = ResourceStorage(FileSystemResourceDriver(directory=self.path))
         self._create(storage)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c4091b16/tests/workflows/api/test_task.py
----------------------------------------------------------------------
diff --git a/tests/workflows/api/test_task.py b/tests/workflows/api/test_task.py
index f919dd7..58f9760 100644
--- a/tests/workflows/api/test_task.py
+++ b/tests/workflows/api/test_task.py
@@ -104,8 +104,8 @@ class TestOperationTask(object):
 
         with context.workflow.current.push(workflow_context):
             api_task = api.task.OperationTask.relationship_instance(
-                instance=operation_name,
-                actor=relationship_instance,
+                name=operation_name,
+                instance=relationship_instance,
                 operation_end=api.task.OperationTask.SOURCE_OPERATION,
                 inputs=inputs,
                 max_attempts=max_attempts,


Mime
View raw message