Fix bug in filesystem's create_collection

This commit is contained in:
Markus Unterwaditzer 2015-03-08 15:00:51 +01:00
parent f17984559a
commit 264023c30d
2 changed files with 10 additions and 14 deletions

View file

@ -14,18 +14,14 @@ from . import StorageTests
class TestFilesystemStorage(StorageTests):
storage_class = FilesystemStorage
@pytest.fixture(autouse=True)
def setup(self, tmpdir):
self.tmpdir = str(tmpdir)
@pytest.fixture
def get_storage_args(self):
def inner(collection=None):
path = self.tmpdir
def get_storage_args(self, tmpdir):
def inner(collection='test'):
rv = {'path': str(tmpdir), 'fileext': '.txt', 'collection':
collection}
if collection is not None:
os.makedirs(os.path.join(path, collection))
path = os.path.join(path, collection)
return {'path': path, 'fileext': '.txt', 'collection': collection}
rv = self.storage_class.create_collection(**rv)
return rv
return inner
def test_is_not_directory(self, tmpdir):

View file

@ -69,12 +69,12 @@ class FilesystemStorage(Storage):
@classmethod
def create_collection(cls, collection, **kwargs):
rv = dict(kwargs)
kwargs = dict(kwargs)
if collection is not None:
rv['path'] = os.path.join(rv['path'], collection)
checkdir(expand_path(rv['path']), create=True)
rv['collection'] = collection
kwargs['path'] = os.path.join(kwargs['path'], collection)
checkdir(expand_path(kwargs['path']), create=True)
kwargs['collection'] = collection
return kwargs
def _get_filepath(self, href):