Restructure that mess

This commit is contained in:
Markus Unterwaditzer 2014-02-26 20:41:35 +01:00
parent 65548f72f4
commit 784c0edb5d

View file

@ -16,41 +16,50 @@ import shutil
from vdirsyncer.storage.caldav import CaldavStorage
from . import StorageTests
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse as WerkzeugResponse
# All of radicale is already global state, there's nothing we can do
os.environ['RADICALE_CONFIG'] = ''
import radicale.config as radicale_config
radicale_config.set('storage', 'type', 'filesystem')
radicale_config.set('storage', 'filesystem_folder', None)
radicale_config.set('rights', 'type', 'None')
from radicale import Application
import radicale.log
radicale.log.start()
class Response(object):
'''Fake API of requests module'''
def __init__(self, x):
self.x = x
self.status_code = x.status_code
self.content = x.get_data(as_text=False)
self.headers = x.headers
def raise_for_status(self):
'''copied from requests itself'''
if 400 <= self.status_code < 600:
from requests.exceptions import HTTPError
raise HTTPError(str(self.status_code))
class CaldavStorageTests(TestCase, StorageTests):
tmpdir = None
def _get_storage(self, **kwargs):
self.tmpdir = tempfile.mkdtemp()
os.environ['RADICALE_CONFIG'] = ''
import radicale.config as radicale_config
radicale_config.set('storage', 'type', 'filesystem')
radicale_config.set('storage', 'filesystem_folder', self.tmpdir)
radicale_config.set('rights', 'type', 'None')
from radicale import Application
app = Application()
import radicale.log
radicale.log.start()
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse as WerkzeugResponse
class Response(object):
'''Fake API of requests module'''
def __init__(self, x):
self.x = x
self.status_code = x.status_code
self.content = x.get_data(as_text=False)
self.headers = x.headers
def raise_for_status(self):
'''copied from requests itself'''
if 400 <= self.status_code < 600:
from requests.exceptions import HTTPError
raise HTTPError(str(self.status_code))
c = Client(app, WerkzeugResponse)
server = 'http://127.0.0.1'
calendar_path = '/bob/test.ics/'
full_url = server + calendar_path
def x(method, item, data=None, headers=None):
assert '/' not in item
url = calendar_path + item