mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-05 10:45:51 +00:00
More tests
This commit is contained in:
parent
cff730e02e
commit
8c120d84ef
5 changed files with 15 additions and 8 deletions
|
|
@ -105,3 +105,7 @@ class StorageTests(object):
|
|||
((href, etag),) = s.list()
|
||||
item, etag = s.get(href)
|
||||
assert item.raw in set(x.raw for x in items)
|
||||
|
||||
def test_collection_arg(self):
|
||||
s = self.storage_class(**self.get_storage_args(collection='asd'))
|
||||
assert s.collection == 'asd'
|
||||
|
|
|
|||
|
|
@ -97,9 +97,7 @@ class DavStorageTests(StorageTests):
|
|||
|
||||
def get_storage_args(self, collection=None):
|
||||
url = 'http://127.0.0.1/bob/'
|
||||
if collection is not None:
|
||||
url += '{}{}'.format(collection, self.storage_class.fileext)
|
||||
return {'url': url}
|
||||
return {'url': url, 'collection': collection}
|
||||
|
||||
def teardown_method(self, method):
|
||||
self.app = None
|
||||
|
|
|
|||
|
|
@ -22,6 +22,5 @@ class FilesystemStorageTests(TestCase, StorageTests):
|
|||
def get_storage_args(self, collection=None):
|
||||
path = self.tmpdir
|
||||
if collection is not None:
|
||||
path = os.path.join(path, collection)
|
||||
os.makedirs(path)
|
||||
return {'path': path, 'fileext': '.txt'}
|
||||
os.makedirs(os.path.join(path, collection))
|
||||
return {'path': path, 'fileext': '.txt', 'collection': collection}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,11 @@ class MemoryStorageTests(TestCase, StorageTests):
|
|||
|
||||
storage_class = MemoryStorage
|
||||
|
||||
def get_storage_args(collection=None):
|
||||
return {}
|
||||
def get_storage_args(self, **kwargs):
|
||||
return kwargs
|
||||
|
||||
def test_discover(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
||||
def test_collection_arg(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
|
|
|||
|
|
@ -36,12 +36,15 @@ class FilesystemStorage(Storage):
|
|||
super(FilesystemStorage, self).__init__(**kwargs)
|
||||
if collection is not None:
|
||||
path = os.path.join(path, collection)
|
||||
self.collection = collection
|
||||
self.path = expand_path(path)
|
||||
self.encoding = encoding
|
||||
self.fileext = fileext
|
||||
|
||||
@classmethod
|
||||
def discover(cls, path, **kwargs):
|
||||
if kwargs.pop('collection', None) is not None:
|
||||
raise TypeError('collection argument must not be given.')
|
||||
for collection in os.listdir(path):
|
||||
s = cls(path=path, collection=collection, **kwargs)
|
||||
if next(s.list(), None) is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue