From 21e694c98c2df4df005c0e2e55ca167b1b286584 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 18 Mar 2014 16:59:30 +0100 Subject: [PATCH] More fixes --- install-deps.sh | 1 - run-tests.sh | 17 +++++++++++++++++ tests/storage/__init__.py | 6 +++--- tests/storage/dav/__init__.py | 3 ++- tests/storage/dav/_owncloud.py | 22 +++++----------------- 5 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 run-tests.sh diff --git a/install-deps.sh b/install-deps.sh index e2b4446..cbd1524 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -21,7 +21,6 @@ radicale_storage_filesystem() { true; } davserver_owncloud() { - pip install paste git clone git@github.com:untitaker/owncloud-testserver.git cd ./owncloud-testserver/ sh install.sh diff --git a/run-tests.sh b/run-tests.sh new file mode 100644 index 0000000..046fb68 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,17 @@ +#!/bin/sh +[[ -z "$DAV_SERVER" ]] && DAV_SERVER=radicale +[[ -z "$RADICALE_STORAGE" ]] && RADICALE_STORAGE=filesystem + +davserver_radicale() { true; } +davserver_radicale_git() { true; } + +davserver_owncloud() { + sh ./owncloud-testserver/php.sh +} + + +davserver_$DAV_SERVER & +DAVSERVER_PID=$! +py.test ./tests/ +kill -9 $DAVSERVER_PID +wait diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index e859914..38e24c9 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -98,7 +98,7 @@ class StorageTests(object): def test_discover(self): items = [] for i in range(4): - s = self.storage_class(**self.get_storage_args(collection=str(i))) + s = self.storage_class(**self.get_storage_args(collection='test' + str(i+1))) items.append(self._create_bogus_item(str(i))) s.upload(items[-1]) @@ -110,7 +110,7 @@ class StorageTests(object): 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')) + s = self.storage_class(**self.get_storage_args(collection='test2')) # Can't do stronger assertion because of radicale, which needs a # fileextension to guess the collection type. - assert 'asd' in s.collection + assert 'test2' in s.collection diff --git a/tests/storage/dav/__init__.py b/tests/storage/dav/__init__.py index 5a26664..e8a31bb 100644 --- a/tests/storage/dav/__init__.py +++ b/tests/storage/dav/__init__.py @@ -13,6 +13,7 @@ import os from .. import StorageTests import vdirsyncer.exceptions as exceptions from vdirsyncer.storage.base import Item +import requests.exceptions dav_server = os.environ.get('DAV_SERVER', '').strip() or 'radicale' @@ -30,6 +31,6 @@ class DavStorageTests(ServerMixin, StorageTests): s = self._get_storage() try: s.upload(item) - except exceptions.Error: + except (exceptions.Error, requests.exceptions.HTTPError): pass assert not list(s.list()) diff --git a/tests/storage/dav/_owncloud.py b/tests/storage/dav/_owncloud.py index a42601e..a9ce3ae 100644 --- a/tests/storage/dav/_owncloud.py +++ b/tests/storage/dav/_owncloud.py @@ -9,19 +9,11 @@ :license: MIT, see LICENSE for more details. ''' -from paste.cgiapp import CGIApplication from vdirsyncer.utils import expand_path -from ._radicale import wsgi_setup import subprocess import os owncloud_repo = expand_path(os.path.join(os.path.dirname(__file__), '../../../owncloud-testserver/')) -app = CGIApplication(None, 'php.cgi', [owncloud_repo], include_os_environ=False, query_string=None) - -def middleware(environ, start_response): - print(environ) - environ['REQUEST_URI'] = 'http://127.0.0.1' + environ['PATH_INFO'] - return app(environ, start_response) class ServerMixin(object): storage_class = None @@ -29,22 +21,18 @@ class ServerMixin(object): def setup_method(self, method): subprocess.call([os.path.join(owncloud_repo, 'install.sh')]) - self.wsgi_teardown = wsgi_setup(middleware) def get_storage_args(self, collection='test'): assert self.storage_class.fileext in ('.ics', '.vcf') + url = 'http://127.0.0.1:8080' if self.storage_class.fileext == '.vcf': - url = 'http://127.0.0.1/remote.php/carddav/addressbooks/asdf/' + url += '/remote.php/carddav/addressbooks/asdf/' else: - url = 'http://127.0.0.1/remote.php/carddav/addressbooks/asdf/' + url += '/remote.php/carddav/addressbooks/asdf/' if collection is not None: + # the following collections are setup in ownCloud assert collection in ('test', 'test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8', 'test9', 'test10') - return {'url': url, 'collection': collection} - - def teardown_method(self, method): - if self.wsgi_teardown is not None: - self.wsgi_teardown() - self.wsgi_teardown = None + return {'url': url, 'collection': collection, 'username': 'asdf', 'password': 'asdf'}