mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Some smaller changes to testsuite
This commit is contained in:
parent
fde7efd52e
commit
7bbc8b87da
4 changed files with 35 additions and 44 deletions
|
|
@ -17,7 +17,7 @@ from vdirsyncer.utils.compat import iteritems, text_type
|
|||
from .. import SIMPLE_TEMPLATE, assert_item_equals
|
||||
|
||||
|
||||
class StorageTests(object):
|
||||
class BaseStorageTests(object):
|
||||
item_template = SIMPLE_TEMPLATE
|
||||
|
||||
def _create_bogus_item(self, item_template=None):
|
||||
|
|
@ -111,6 +111,34 @@ class StorageTests(object):
|
|||
s.upload(self._create_bogus_item())
|
||||
assert list(s.list())
|
||||
|
||||
def test_has(self):
|
||||
s = self._get_storage()
|
||||
assert not s.has('asd')
|
||||
href, etag = s.upload(self._create_bogus_item())
|
||||
assert s.has(href)
|
||||
assert not s.has('asd')
|
||||
|
||||
def test_update_others_stay_the_same(self):
|
||||
s = self._get_storage()
|
||||
info = dict([
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item())
|
||||
])
|
||||
|
||||
assert dict(
|
||||
(href, etag) for href, item, etag
|
||||
in s.get_multi(href for href, etag in iteritems(info))
|
||||
) == info
|
||||
|
||||
def test_repr(self):
|
||||
s = self._get_storage()
|
||||
assert self.storage_class.__name__ in repr(s)
|
||||
|
||||
|
||||
class SupportsCollections(object):
|
||||
|
||||
def test_discover(self):
|
||||
collections = set()
|
||||
|
||||
|
|
@ -159,27 +187,6 @@ class StorageTests(object):
|
|||
# fileextension to guess the collection type.
|
||||
assert 'test2' in s.collection
|
||||
|
||||
def test_has(self):
|
||||
s = self._get_storage()
|
||||
assert not s.has('asd')
|
||||
href, etag = s.upload(self._create_bogus_item())
|
||||
assert s.has(href)
|
||||
assert not s.has('asd')
|
||||
|
||||
def test_update_others_stay_the_same(self):
|
||||
s = self._get_storage()
|
||||
info = dict([
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item()),
|
||||
s.upload(self._create_bogus_item())
|
||||
])
|
||||
|
||||
assert dict(
|
||||
(href, etag) for href, item, etag
|
||||
in s.get_multi(href for href, etag in iteritems(info))
|
||||
) == info
|
||||
|
||||
def test_repr(self):
|
||||
s = self._get_storage()
|
||||
assert self.storage_class.__name__ in repr(s)
|
||||
class StorageTests(BaseStorageTests, SupportsCollections):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -10,21 +10,12 @@
|
|||
|
||||
from vdirsyncer.storage.memory import MemoryStorage
|
||||
|
||||
from . import StorageTests
|
||||
from . import BaseStorageTests
|
||||
|
||||
|
||||
class TestMemoryStorage(StorageTests):
|
||||
class TestMemoryStorage(BaseStorageTests):
|
||||
|
||||
storage_class = MemoryStorage
|
||||
|
||||
def get_storage_args(self, **kwargs):
|
||||
return kwargs
|
||||
|
||||
def test_discover(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
||||
def test_discover_collection_arg(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
||||
def test_collection_arg(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import pytest
|
|||
|
||||
from vdirsyncer.storage.singlefile import SingleFileStorage
|
||||
|
||||
from . import StorageTests
|
||||
from . import BaseStorageTests
|
||||
from .. import EVENT_TEMPLATE, assert_item_equals
|
||||
|
||||
|
||||
class TestSingleFileStorage(StorageTests):
|
||||
class TestSingleFileStorage(BaseStorageTests):
|
||||
|
||||
storage_class = SingleFileStorage
|
||||
item_template = EVENT_TEMPLATE
|
||||
|
|
@ -27,12 +27,6 @@ class TestSingleFileStorage(StorageTests):
|
|||
def get_storage_args(self, **kwargs):
|
||||
return dict(path=self._path)
|
||||
|
||||
def test_discover(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
||||
def test_discover_collection_arg(self):
|
||||
'''This test doesn't make any sense here.'''
|
||||
|
||||
def test_collection_arg(self, tmpdir):
|
||||
with pytest.raises(ValueError):
|
||||
self.storage_class(str(tmpdir.join('foo.ics')), collection='ha')
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ def split_collection(text, inline=(u'VTIMEZONE',),
|
|||
'''Emits items in the order they occur in the text.'''
|
||||
assert isinstance(text, text_type)
|
||||
collections = icalendar.cal.Component.from_ical(text, multiple=True)
|
||||
assert collections
|
||||
collection_name = None
|
||||
|
||||
for collection in collections:
|
||||
|
|
|
|||
Loading…
Reference in a new issue