Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9F17F200BCD for ; Sun, 27 Nov 2016 17:16:44 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9CD3E160B12; Sun, 27 Nov 2016 16:16:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4BF78160B01 for ; Sun, 27 Nov 2016 17:16:43 +0100 (CET) Received: (qmail 3437 invoked by uid 500); 27 Nov 2016 16:16:42 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 3426 invoked by uid 99); 27 Nov 2016 16:16:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Nov 2016 16:16:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 13B40C08D9 for ; Sun, 27 Nov 2016 16:16:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.22 X-Spam-Level: X-Spam-Status: No, score=-5.22 tagged_above=-999 required=6.31 tests=[HK_RANDOM_FROM=0.999, KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id AG7zr8is_HUJ for ; Sun, 27 Nov 2016 16:16:40 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 75AEB5F478 for ; Sun, 27 Nov 2016 16:16:39 +0000 (UTC) Received: (qmail 3390 invoked by uid 99); 27 Nov 2016 16:16:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Nov 2016 16:16:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C58A8DFF13; Sun, 27 Nov 2016 16:16:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mxmrlv@apache.org To: dev@ariatosca.incubator.apache.org Date: Sun, 27 Nov 2016 16:16:41 -0000 Message-Id: <954fcd4f25af4e1e976d22a1589b4f1e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/4] incubator-ariatosca git commit: fixed tests archived-at: Sun, 27 Nov 2016 16:16:44 -0000 fixed 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/6feb4cb3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/6feb4cb3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/6feb4cb3 Branch: refs/heads/SQLAlchemy-based-models Commit: 6feb4cb31232077d3b3bc998a67c94904834ab04 Parents: 7b473b6 Author: mxmrlv Authored: Sun Nov 27 18:12:43 2016 +0200 Committer: mxmrlv Committed: Sun Nov 27 18:12:43 2016 +0200 ---------------------------------------------------------------------- aria/__init__.py | 30 ++++++++-------- aria/storage/__init__.py | 33 +++++++++++------ aria/storage/api_driver/__init__.py | 2 +- aria/storage/api_driver/file_system.py | 52 +++++++++++++-------------- aria/storage/api_driver/in_memory.py | 12 +++---- aria/storage/storage_api.py | 17 ++++----- tests/storage/__init__.py | 1 + tests/storage/test_model_storage.py | 9 ++--- tests/storage/test_resource_storage.py | 55 ++++++++++++++++------------- 9 files changed, 113 insertions(+), 98 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/__init__.py ---------------------------------------------------------------------- diff --git a/aria/__init__.py b/aria/__init__.py index d911084..4dd23c9 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -23,7 +23,7 @@ import pkgutil from .VERSION import version as __version__ from .orchestrator.decorators import workflow, operation -from .storage import models, Storage +from . import storage from . import ( utils, parser, @@ -64,20 +64,20 @@ def application_model_storage(api): """ if api not in _model_storage: - _model_storage[api] = Storage( + _model_storage[api] = storage.ModelStorage( api, items=[ - models.Node, - models.NodeInstance, - models.Plugin, - models.Blueprint, - models.Snapshot, - models.Deployment, - models.DeploymentUpdate, - models.DeploymentUpdateStep, - models.DeploymentModification, - models.Execution, - models.ProviderContext, - models.Task, + storage.models.Node, + storage.models.NodeInstance, + storage.models.Plugin, + storage.models.Blueprint, + storage.models.Snapshot, + storage.models.Deployment, + storage.models.DeploymentUpdate, + storage.models.DeploymentUpdateStep, + storage.models.DeploymentModification, + storage.models.Execution, + storage.models.ProviderContext, + storage.models.Task, ]) return _model_storage[api] @@ -87,7 +87,7 @@ def application_resource_storage(driver): Initiate resource storage for the supplied storage driver """ if driver not in _resource_storage: - _resource_storage[driver] = Storage( + _resource_storage[driver] = storage.ResourceStorage( driver, resources=[ 'blueprint', http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/storage/__init__.py ---------------------------------------------------------------------- diff --git a/aria/storage/__init__.py b/aria/storage/__init__.py index 7617ad9..9cb6c77 100644 --- a/aria/storage/__init__.py +++ b/aria/storage/__init__.py @@ -41,12 +41,11 @@ API: from aria.logger import LoggerMixin from aria.storage import storage_api from aria.storage.exceptions import StorageError -from . import models, exceptions, storage_api +from . import models, exceptions, storage_api, structures __all__ = ( 'ModelStorage', - 'ResourceStorage', 'models', 'structures', ) @@ -56,7 +55,8 @@ class Storage(LoggerMixin): """ Represents the storage """ - def __init__(self, api, items=(), **kwargs): + def __init__(self, api, items=(), api_params=None, **kwargs): + self._api_params = api_params or {} super(Storage, self).__init__(**kwargs) self.api = api self.registered = {} @@ -66,7 +66,7 @@ class Storage(LoggerMixin): self, name=self.__class__.__name__)) def __repr__(self): - return '{name}'.format(name=self.__class__.__name__) + return '{name}(api={self.api})'.format(name=self.__class__.__name__, self=self) def __getattr__(self, item): try: @@ -74,12 +74,23 @@ class Storage(LoggerMixin): except KeyError: return super(Storage, self).__getattribute__(item) - def register(self, model_cls): - """ - Registers the model type in the resource storage manager. - :param model_cls: the model to register. - """ - model_name = storage_api.generate_lower_name(model_cls) - self.registered[model_name] = self.api(model_name, model_cls) + def register(self, name): + raise NotImplementedError("BBBBBBB") + + +class ResourceStorage(Storage): + def register(self, name): + self.registered[name] = self.api(name=name, + **self._api_params) + self.registered[name].create() + self.logger.debug('setup {name} in storage {self!r}'.format(name=name, self=self)) + + +class ModelStorage(Storage): + def register(self, model): + model_name = storage_api.generate_lower_name(model) + self.registered[model_name] = self.api(name=model_name, + model_cls=model, + **self._api_params) self.registered[model_name].create() self.logger.debug('setup {name} in storage {self!r}'.format(name=model_name, self=self)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/storage/api_driver/__init__.py ---------------------------------------------------------------------- diff --git a/aria/storage/api_driver/__init__.py b/aria/storage/api_driver/__init__.py index 48fa903..9d0095b 100644 --- a/aria/storage/api_driver/__init__.py +++ b/aria/storage/api_driver/__init__.py @@ -13,6 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .file_system import FileSystemModelAPI, FileSystemResourceDriver +from .file_system import FileSystemModelAPI, FileSystemResourceAPI from .in_memory import InMemoryModelAPI from .sql import SQLAlchemyModelAPI http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/storage/api_driver/file_system.py ---------------------------------------------------------------------- diff --git a/aria/storage/api_driver/file_system.py b/aria/storage/api_driver/file_system.py index bbe3088..45ecbe8 100644 --- a/aria/storage/api_driver/file_system.py +++ b/aria/storage/api_driver/file_system.py @@ -12,11 +12,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import distutils import os import shutil from functools import partial from multiprocessing import RLock +from distutils import dir_util import jsonpickle @@ -55,12 +55,12 @@ class FileSystemAPI(storage_api.StorageAPI): class FileSystemModelAPI(storage_api.ModelAPI, FileSystemAPI): """ - FileSystemModelDriver context manager. + File system model storage. """ def __init__(self, directory, **kwargs): """ - File system implementation for storage driver. + File system implementation for storage api. :param str directory: root dir for storage. """ super(FileSystemModelAPI, self).__init__(**kwargs) @@ -72,7 +72,7 @@ class FileSystemModelAPI(storage_api.ModelAPI, FileSystemAPI): return '{cls.__name__}(directory={self.directory})'.format( cls=self.__class__, self=self) - def create(self): + def create(self, **kwargs): """ Create directory in storage by path. tries to create the root directory as well. @@ -135,22 +135,22 @@ class FileSystemModelAPI(storage_api.ModelAPI, FileSystemAPI): :param kwargs: the fields to update. :return: """ - entry_dict = self.get(self.name, entry_id) + entry_dict = self.get(entry_id) entry_dict.update(**kwargs) - self.store(self.name, entry_dict) + self.store(entry_dict) -class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): +class FileSystemResourceAPI(storage_api.ResourceAPI, FileSystemAPI): """ - FileSystemResourceDriver context manager. + File system resource storage. """ def __init__(self, directory, **kwargs): """ - File system implementation for storage driver. + File system implementation for storage api. :param str directory: root dir for storage. """ - super(FileSystemResourceDriver, self).__init__(**kwargs) + super(FileSystemResourceAPI, self).__init__(**kwargs) self.directory = directory self._join_path = partial(os.path.join, self.directory) @@ -158,11 +158,11 @@ class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): return '{cls.__name__}(directory={self.directory})'.format( cls=self.__class__, self=self) - def create(self): + def create(self, **kwargs): """ Create directory in storage by path. tries to create the root directory as well. - :param basestring name: path of file in storage. + :param str name: path of file in storage. """ try: os.makedirs(self.directory) @@ -170,13 +170,13 @@ class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): pass os.makedirs(self._join_path(self.name)) - def data(self, entry_id, path=None): + def data(self, entry_id, path=None, **_): """ Retrieve the content of a file system storage resource. - :param basestring entry_type: the type of the entry. - :param basestring entry_id: the id of the entry. - :param basestring path: a path to a specific resource. + :param str entry_type: the type of the entry. + :param str entry_id: the id of the entry. + :param str path: a path to a specific resource. :return: the content of the file :rtype: bytes """ @@ -192,14 +192,14 @@ class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): with open(resource, 'rb') as resource_file: return resource_file.read() - def download(self, entry_id, destination, path=None): + def download(self, entry_id, destination, path=None, **_): """ Download a specific file or dir from the file system resource storage. - :param basestring entry_type: the name of the entry. - :param basestring entry_id: the id of the entry - :param basestring destination: the destination of the files. - :param basestring path: a path on the remote machine relative to the root of the entry. + :param str entry_type: the name of the entry. + :param str entry_id: the id of the entry + :param str destination: the destination of the files. + :param str path: a path on the remote machine relative to the root of the entry. """ resource_relative_path = os.path.join(self.name, entry_id, path or '') resource = os.path.join(self.directory, resource_relative_path) @@ -208,14 +208,14 @@ class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): if os.path.isfile(resource): shutil.copy2(resource, destination) else: - distutils.dir_util.copy_tree(resource, destination) # pylint: disable=no-member + dir_util.copy_tree(resource, destination) # pylint: disable=no-member - def upload(self, entry_id, source, path=None): + def upload(self, entry_id, source, path=None, **_): """ Uploads a specific file or dir to the file system resource storage. - :param basestring entry_type: the name of the entry. - :param basestring entry_id: the id of the entry + :param str entry_type: the name of the entry. + :param str entry_id: the id of the entry :param source: the source of the files to upload. :param path: the destination of the file/s relative to the entry root dir. """ @@ -226,4 +226,4 @@ class FileSystemResourceDriver(storage_api.ResourceAPI, FileSystemAPI): if os.path.isfile(source): shutil.copy2(source, destination) else: - distutils.dir_util.copy_tree(source, destination) # pylint: disable=no-member + dir_util.copy_tree(source, destination) # pylint: disable=no-member http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/storage/api_driver/in_memory.py ---------------------------------------------------------------------- diff --git a/aria/storage/api_driver/in_memory.py b/aria/storage/api_driver/in_memory.py index 1a93427..b2d76f1 100644 --- a/aria/storage/api_driver/in_memory.py +++ b/aria/storage/api_driver/in_memory.py @@ -45,7 +45,7 @@ class InMemoryModelAPI(storage_api.ModelAPI): Creates the model in the storage. """ with self.connect(): - storage[self.model_name] = {} + storage[self.name] = {} self._setup_pointers_mapping() def _setup_pointers_mapping(self,): @@ -66,7 +66,7 @@ class InMemoryModelAPI(storage_api.ModelAPI): :rtype: Model """ with self.connect(): - data = storage[self.model_name][entry_id] + data = storage[self.name][entry_id] data.update(self._get_pointers(data, **kwargs)) return self.model_cls(**data) @@ -79,7 +79,7 @@ class InMemoryModelAPI(storage_api.ModelAPI): with self.connect(): data = entry.fields_dict data.update(self._store_pointers(data, **kwargs)) - storage[self.model_name][entry.id] = data + storage[self.name][entry.id] = data def delete(self, entry_id, **kwargs): """ @@ -90,14 +90,14 @@ class InMemoryModelAPI(storage_api.ModelAPI): entry = self.get(entry_id) with self.connect(): self._delete_pointers(entry, **kwargs) - storage[self.model_name].pop(entry_id) + storage[self.name].pop(entry_id) def iter(self, **kwargs): """ Generator over the entries of model in storage. """ with self.connect(): - for data in storage[self.model_name].values(): + for data in storage[self.name].values(): data.update(self._get_pointers(data, **kwargs)) yield self.model_cls(**data) @@ -110,7 +110,7 @@ class InMemoryModelAPI(storage_api.ModelAPI): :return: """ with self.connect(): - storage[self.model_name][entry_id].update(**kwargs) + storage[self.name][entry_id].update(**kwargs) def _get_pointers(self, data, **kwargs): pointers = {} http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/aria/storage/storage_api.py ---------------------------------------------------------------------- diff --git a/aria/storage/storage_api.py b/aria/storage/storage_api.py index 3d4d8ce..8fa6e7f 100644 --- a/aria/storage/storage_api.py +++ b/aria/storage/storage_api.py @@ -18,8 +18,13 @@ from . import exceptions class StorageAPI(object): - def __init__(self, *args, **kwargs): + def __init__(self, name, *args, **kwargs): super(StorageAPI, self).__init__(*args, **kwargs) + self._name = name + + @property + def name(self): + return self._name def create(self, model_name, **kwargs): raise NotImplementedError('Subclass must implement abstract create method') @@ -42,22 +47,14 @@ class StorageAPI(object): class ModelAPI(StorageAPI): - def __init__(self, model_name, model_cls, **kwargs): + def __init__(self, model_cls, **kwargs): super(ModelAPI, self).__init__(**kwargs) - self._model_name = model_name self._model_cls = model_cls @property - def model_name(self): - return self._model_name - - @property def model_cls(self): return self._model_cls - def create(self, **kwargs): - raise NotImplementedError('Subclass must implement abstract create method') - def get(self, model_name, entry_id, **kwargs): raise NotImplementedError('Subclass must implement abstract get method') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/tests/storage/__init__.py ---------------------------------------------------------------------- diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index 538729a..d5720e8 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -16,6 +16,7 @@ from tempfile import mkdtemp from shutil import rmtree + class TestFileSystem(object): def setup_method(self): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/tests/storage/test_model_storage.py ---------------------------------------------------------------------- diff --git a/tests/storage/test_model_storage.py b/tests/storage/test_model_storage.py index c5879ae..3288e93 100644 --- a/tests/storage/test_model_storage.py +++ b/tests/storage/test_model_storage.py @@ -18,7 +18,8 @@ import pytest from aria import application_model_storage from aria.storage import ( - Storage, + ModelStorage, + ResourceStorage, models, exceptions, api_driver as storage_api, @@ -27,7 +28,7 @@ from aria.storage import ( def test_storage_base(): api = storage_api.InMemoryModelAPI - storage = Storage(api) + storage = ModelStorage(api) assert storage.api == api @@ -36,7 +37,7 @@ def test_storage_base(): def test_model_storage(): - storage = Storage(storage_api.InMemoryModelAPI) + storage = ModelStorage(storage_api.InMemoryModelAPI) storage.register(models.ProviderContext) pc = models.ProviderContext(context={}, name='context_name', id='id1') @@ -56,7 +57,7 @@ def test_model_storage(): def test_storage_driver(): - storage = Storage(storage_api.InMemoryModelAPI) + storage = ModelStorage(storage_api.InMemoryModelAPI) storage.register(models.ProviderContext) pc = models.ProviderContext(context={}, name='context_name', id='id2') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6feb4cb3/tests/storage/test_resource_storage.py ---------------------------------------------------------------------- diff --git a/tests/storage/test_resource_storage.py b/tests/storage/test_resource_storage.py index 918b270..42e69f5 100644 --- a/tests/storage/test_resource_storage.py +++ b/tests/storage/test_resource_storage.py @@ -18,15 +18,17 @@ import tempfile import pytest -from aria.storage.exceptions import StorageError -from aria.storage import ResourceStorage, FileSystemResourceDriver +from aria.storage import ( + api_driver, + exceptions, + ResourceStorage +) from . import TestFileSystem class TestResourceStorage(TestFileSystem): def _create(self, storage): storage.register('blueprint') - storage.setup() def _upload(self, storage, tmp_path, id): with open(tmp_path, 'w') as f: @@ -41,24 +43,27 @@ class TestResourceStorage(TestFileSystem): storage.blueprint.upload(entry_id=id, source=tmp_dir) + def _create_storage(self): + return ResourceStorage(api_driver.FileSystemResourceAPI, + api_params=dict(directory=self.path)) + def test_name(self): - driver = FileSystemResourceDriver(directory=self.path) - storage = ResourceStorage(driver, resources=['blueprint']) - assert repr(storage) == 'ResourceStorage(driver={driver})'.format( - driver=driver - ) - assert repr(storage.registered['blueprint']) == ( - 'ResourceApi(driver={driver}, resource={resource_name})'.format( - driver=driver, - resource_name='blueprint')) + api = api_driver.FileSystemResourceAPI + storage = ResourceStorage(api_driver.FileSystemResourceAPI, + items=['blueprint'], + api_params=dict(directory=self.path)) + assert repr(storage) == 'ResourceStorage(api={api})'.format(api=api) + assert 'directory={resource_dir}'.format(api=api, resource_dir=self.path) in \ + repr(storage.registered['blueprint']) def test_create(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) assert os.path.exists(os.path.join(self.path, 'blueprint')) def test_upload_file(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = ResourceStorage(api_driver.FileSystemResourceAPI, + api_params=dict(directory=self.path)) self._create(storage) tmpfile_path = tempfile.mkstemp(suffix=self.__class__.__name__, dir=self.path)[1] self._upload(storage, tmpfile_path, id='blueprint_id') @@ -74,7 +79,7 @@ class TestResourceStorage(TestFileSystem): assert f.read() == 'fake context' def test_download_file(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmpfile_path = tempfile.mkstemp(suffix=self.__class__.__name__, dir=self.path)[1] tmpfile_name = os.path.basename(tmpfile_path) @@ -90,19 +95,19 @@ class TestResourceStorage(TestFileSystem): assert f.read() == 'fake context' def test_download_non_existing_file(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) - with pytest.raises(StorageError): + with pytest.raises(exceptions.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)) + storage = self._create_storage() self._create(storage) - with pytest.raises(StorageError): + with pytest.raises(exceptions.StorageError): storage.blueprint.data(entry_id='blueprint_id', path='fake_path') def test_data_file(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmpfile_path = tempfile.mkstemp(suffix=self.__class__.__name__, dir=self.path)[1] self._upload(storage, tmpfile_path, 'blueprint_id') @@ -110,7 +115,7 @@ class TestResourceStorage(TestFileSystem): assert storage.blueprint.data(entry_id='blueprint_id') == 'fake context' def test_upload_dir(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmp_dir = tempfile.mkdtemp(suffix=self.__class__.__name__, dir=self.path) second_level_tmp_dir = tempfile.mkdtemp(dir=tmp_dir) @@ -127,7 +132,7 @@ class TestResourceStorage(TestFileSystem): assert os.path.isfile(destination) def test_upload_path_in_dir(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmp_dir = tempfile.mkdtemp(suffix=self.__class__.__name__, dir=self.path) second_level_tmp_dir = tempfile.mkdtemp(dir=tmp_dir) @@ -151,7 +156,7 @@ class TestResourceStorage(TestFileSystem): os.path.basename(second_update_file))) def test_download_dir(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmp_dir = tempfile.mkdtemp(suffix=self.__class__.__name__, dir=self.path) second_level_tmp_dir = tempfile.mkdtemp(dir=tmp_dir) @@ -174,7 +179,7 @@ class TestResourceStorage(TestFileSystem): assert f.read() == 'fake context' def test_data_dir(self): - storage = ResourceStorage(FileSystemResourceDriver(directory=self.path)) + storage = self._create_storage() self._create(storage) tmp_dir = tempfile.mkdtemp(suffix=self.__class__.__name__, dir=self.path) @@ -183,5 +188,5 @@ class TestResourceStorage(TestFileSystem): storage.blueprint.upload(entry_id='blueprint_id', source=tmp_dir) - with pytest.raises(StorageError): + with pytest.raises(exceptions.StorageError): storage.blueprint.data(entry_id='blueprint_id')