mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +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()
|
((href, etag),) = s.list()
|
||||||
item, etag = s.get(href)
|
item, etag = s.get(href)
|
||||||
assert item.raw in set(x.raw for x in items)
|
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):
|
def get_storage_args(self, collection=None):
|
||||||
url = 'http://127.0.0.1/bob/'
|
url = 'http://127.0.0.1/bob/'
|
||||||
if collection is not None:
|
return {'url': url, 'collection': collection}
|
||||||
url += '{}{}'.format(collection, self.storage_class.fileext)
|
|
||||||
return {'url': url}
|
|
||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
self.app = None
|
self.app = None
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,5 @@ class FilesystemStorageTests(TestCase, StorageTests):
|
||||||
def get_storage_args(self, collection=None):
|
def get_storage_args(self, collection=None):
|
||||||
path = self.tmpdir
|
path = self.tmpdir
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
path = os.path.join(path, collection)
|
os.makedirs(os.path.join(path, collection))
|
||||||
os.makedirs(path)
|
return {'path': path, 'fileext': '.txt', 'collection': collection}
|
||||||
return {'path': path, 'fileext': '.txt'}
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,11 @@ class MemoryStorageTests(TestCase, StorageTests):
|
||||||
|
|
||||||
storage_class = MemoryStorage
|
storage_class = MemoryStorage
|
||||||
|
|
||||||
def get_storage_args(collection=None):
|
def get_storage_args(self, **kwargs):
|
||||||
return {}
|
return kwargs
|
||||||
|
|
||||||
def test_discover(self):
|
def test_discover(self):
|
||||||
'''This test doesn't make any sense here.'''
|
'''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)
|
super(FilesystemStorage, self).__init__(**kwargs)
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
path = os.path.join(path, collection)
|
path = os.path.join(path, collection)
|
||||||
|
self.collection = collection
|
||||||
self.path = expand_path(path)
|
self.path = expand_path(path)
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
self.fileext = fileext
|
self.fileext = fileext
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def discover(cls, path, **kwargs):
|
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):
|
for collection in os.listdir(path):
|
||||||
s = cls(path=path, collection=collection, **kwargs)
|
s = cls(path=path, collection=collection, **kwargs)
|
||||||
if next(s.list(), None) is not None:
|
if next(s.list(), None) is not None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue