From 78ea006f6e265eb098a90dbf918f26fbefc6c08a Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 9 Mar 2014 21:55:20 +0100 Subject: [PATCH] Add radicale db storage as test --- .travis.yml | 6 +++-- tests/storage/dav/__init__.py | 47 +++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b9f87e..db6a8a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,10 @@ language: python python: "2.7" env: - - DAV_SERVER=radicale - - DAV_SERVER=radicale-git + - DAV_SERVER=radicale RADICALE_STORAGE=filesystem + - DAV_SERVER=radicale RADICALE_STORAGE=database + - DAV_SERVER=radicale-git RADICALE_STORAGE=filesystem + - DAV_SERVER=radicale-git RADICALE_STORAGE=database install: - "sh install-deps.sh" diff --git a/tests/storage/dav/__init__.py b/tests/storage/dav/__init__.py index 9a61eb7..f8350a1 100644 --- a/tests/storage/dav/__init__.py +++ b/tests/storage/dav/__init__.py @@ -27,6 +27,38 @@ from .. import StorageTests import vdirsyncer.exceptions as exceptions from vdirsyncer.storage.base import Item +RADICALE_SCHEMA = ''' +create table collection ( + path varchar(200) not null, + parent_path varchar(200) references collection (path), + primary key (path)); + +create table item ( + name varchar(200) not null, + tag text not null, + collection_path varchar(200) references collection (path), + primary key (name)); + +create table header ( + name varchar(200) not null, + value text not null, + collection_path varchar(200) references collection (path), + primary key (name, collection_path)); + +create table line ( + name text not null, + value text not null, + item_name varchar(200) references item (name), + timestamp bigint not null, + primary key (timestamp)); + +create table property ( + name varchar(200) not null, + value text not null, + collection_path varchar(200) references collection (path), + primary key (name, collection_path)); +''' + def do_the_radicale_dance(tmpdir): # All of radicale is already global state, the cleanliness of the code and @@ -43,10 +75,21 @@ def do_the_radicale_dance(tmpdir): import radicale.config # Now we can set some basic configuration. - radicale.config.set('storage', 'type', 'filesystem') - radicale.config.set('storage', 'filesystem_folder', tmpdir) radicale.config.set('rights', 'type', 'None') + if os.environ.get('RADICALE_STORAGE', 'filesystem') == 'filesystem': + radicale.config.set('storage', 'type', 'filesystem') + radicale.config.set('storage', 'filesystem_folder', tmpdir) + else: + radicale.config.set('storage', 'type', 'database') + radicale.config.set('storage', 'database_url', 'sqlite://') + from radicale.storage import database + + s = database.Session() + for line in RADICALE_SCHEMA.split(';'): + s.execute(line) + s.commit() + # This one is particularly useful with radicale's debugging logs and # pytest-capturelog, however, it is very verbose. #import radicale.log