Restructuring of DAV storage

We will need this when writing CarddavStorage, assuming we can share
much code between them.
This commit is contained in:
Markus Unterwaditzer 2014-03-01 21:36:01 +01:00
parent 0e9c5a9130
commit aa7d2f3eeb
6 changed files with 52 additions and 20 deletions

View file

@ -12,9 +12,8 @@ import sys
import json
import ConfigParser
from vdirsyncer.sync import sync
from vdirsyncer.storage.caldav import CaldavStorage
from vdirsyncer.storage.filesystem import FilesystemStorage
from vdirsyncer.utils import expand_path
from vdirsyncer.storage import storage_names
import vdirsyncer.log as log
import argvard
@ -22,12 +21,6 @@ import argvard
cli_logger = log.get('cli')
storage_names = {
'caldav': CaldavStorage,
'filesystem': FilesystemStorage
}
def parse_options(items):
for key, value in items:
if value.lower() in ('yes', 'true', 'on'):

View file

@ -11,3 +11,11 @@
:copyright: (c) 2014 Markus Unterwaditzer
:license: MIT, see LICENSE for more details.
'''
from .dav.caldav import CaldavStorage
from .filesystem import FilesystemStorage
storage_names = {
'caldav': CaldavStorage,
'filesystem': FilesystemStorage
}

View file

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
'''
vdirsyncer.storage.dav
~~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2014 Markus Unterwaditzer
:license: MIT, see LICENSE for more details.
'''

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
'''
vdirsyncer.storage.caldav
vdirsyncer.storage.dav.caldav
~~~~~~~~~~~~~~~~~~~~~~~~~
Original version from khal: https://github.com/geier/khal
@ -9,7 +9,7 @@
:license: MIT, see LICENSE for more details.
'''
from .base import Storage, Item
from ..base import Storage, Item
import vdirsyncer.exceptions as exceptions
from lxml import etree
import requests

View file

@ -1,20 +1,19 @@
# -*- coding: utf-8 -*-
'''
vdirsyncer.tests.storage.test_caldav
vdirsyncer.tests.storage.dav
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using an actual CalDAV server to test the CalDAV storage. Done by using
Werkzeug's test client for WSGI apps. While this is pretty fast, Radicale
has so much global state such that a clean separation of the unit tests is
not guaranteed.
Using an actual CalDAV/CardDAV server to test the CalDAV and CardDAV
storages. Done by using Werkzeug's test client for WSGI apps. While this is
pretty fast, Radicale has so much global state such that a clean separation
of the unit tests is not easy.
:copyright: (c) 2014 Markus Unterwaditzer
:license: MIT, see LICENSE for more details.
'''
__version__ = '0.1.0'
from unittest import TestCase
import tempfile
import shutil
import sys
@ -23,8 +22,7 @@ import os
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse as WerkzeugResponse
from vdirsyncer.storage.caldav import CaldavStorage
from . import StorageTests
from .. import StorageTests
def do_the_radicale_dance(tmpdir):
@ -69,8 +67,9 @@ class Response(object):
raise HTTPError(str(self.status_code))
class CaldavStorageTests(TestCase, StorageTests):
class DavStorageTests(StorageTests):
tmpdir = None
storage_class = None
def _get_storage(self, **kwargs):
self.tmpdir = tempfile.mkdtemp()
@ -90,7 +89,7 @@ class CaldavStorageTests(TestCase, StorageTests):
r = c.open(path=url, method=method, data=data, headers=headers)
r = Response(r)
return r
return CaldavStorage(full_url, _request_func=x)
return self.storage_class(url=full_url, _request_func=x, **kwargs)
def tearDown(self):
self.app = None

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
'''
vdirsyncer.tests.storage.test_caldav
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using an actual CalDAV server to test the CalDAV storage. Done by using
Werkzeug's test client for WSGI apps. While this is pretty fast, Radicale
has so much global state such that a clean separation of the unit tests is
not guaranteed.
:copyright: (c) 2014 Markus Unterwaditzer
:license: MIT, see LICENSE for more details.
'''
__version__ = '0.1.0'
from unittest import TestCase
from vdirsyncer.storage.caldav import CaldavStorage
from . import DavStorageTests
class CaldavStorageTests(TestCase, DavStorageTests):
storage_class = CaldavStorage