mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
More fixes
This commit is contained in:
parent
d61c4fc31b
commit
21e694c98c
5 changed files with 27 additions and 22 deletions
|
|
@ -21,7 +21,6 @@ radicale_storage_filesystem() { true; }
|
||||||
|
|
||||||
|
|
||||||
davserver_owncloud() {
|
davserver_owncloud() {
|
||||||
pip install paste
|
|
||||||
git clone git@github.com:untitaker/owncloud-testserver.git
|
git clone git@github.com:untitaker/owncloud-testserver.git
|
||||||
cd ./owncloud-testserver/
|
cd ./owncloud-testserver/
|
||||||
sh install.sh
|
sh install.sh
|
||||||
|
|
|
||||||
17
run-tests.sh
Normal file
17
run-tests.sh
Normal file
|
|
@ -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
|
||||||
|
|
@ -98,7 +98,7 @@ class StorageTests(object):
|
||||||
def test_discover(self):
|
def test_discover(self):
|
||||||
items = []
|
items = []
|
||||||
for i in range(4):
|
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)))
|
items.append(self._create_bogus_item(str(i)))
|
||||||
s.upload(items[-1])
|
s.upload(items[-1])
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ class StorageTests(object):
|
||||||
assert item.raw in set(x.raw for x in items)
|
assert item.raw in set(x.raw for x in items)
|
||||||
|
|
||||||
def test_collection_arg(self):
|
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
|
# Can't do stronger assertion because of radicale, which needs a
|
||||||
# fileextension to guess the collection type.
|
# fileextension to guess the collection type.
|
||||||
assert 'asd' in s.collection
|
assert 'test2' in s.collection
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import os
|
||||||
from .. import StorageTests
|
from .. import StorageTests
|
||||||
import vdirsyncer.exceptions as exceptions
|
import vdirsyncer.exceptions as exceptions
|
||||||
from vdirsyncer.storage.base import Item
|
from vdirsyncer.storage.base import Item
|
||||||
|
import requests.exceptions
|
||||||
|
|
||||||
|
|
||||||
dav_server = os.environ.get('DAV_SERVER', '').strip() or 'radicale'
|
dav_server = os.environ.get('DAV_SERVER', '').strip() or 'radicale'
|
||||||
|
|
@ -30,6 +31,6 @@ class DavStorageTests(ServerMixin, StorageTests):
|
||||||
s = self._get_storage()
|
s = self._get_storage()
|
||||||
try:
|
try:
|
||||||
s.upload(item)
|
s.upload(item)
|
||||||
except exceptions.Error:
|
except (exceptions.Error, requests.exceptions.HTTPError):
|
||||||
pass
|
pass
|
||||||
assert not list(s.list())
|
assert not list(s.list())
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,11 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from paste.cgiapp import CGIApplication
|
|
||||||
from vdirsyncer.utils import expand_path
|
from vdirsyncer.utils import expand_path
|
||||||
from ._radicale import wsgi_setup
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
owncloud_repo = expand_path(os.path.join(os.path.dirname(__file__), '../../../owncloud-testserver/'))
|
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):
|
class ServerMixin(object):
|
||||||
storage_class = None
|
storage_class = None
|
||||||
|
|
@ -29,22 +21,18 @@ class ServerMixin(object):
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
subprocess.call([os.path.join(owncloud_repo, 'install.sh')])
|
subprocess.call([os.path.join(owncloud_repo, 'install.sh')])
|
||||||
self.wsgi_teardown = wsgi_setup(middleware)
|
|
||||||
|
|
||||||
def get_storage_args(self, collection='test'):
|
def get_storage_args(self, collection='test'):
|
||||||
assert self.storage_class.fileext in ('.ics', '.vcf')
|
assert self.storage_class.fileext in ('.ics', '.vcf')
|
||||||
|
url = 'http://127.0.0.1:8080'
|
||||||
if self.storage_class.fileext == '.vcf':
|
if self.storage_class.fileext == '.vcf':
|
||||||
url = 'http://127.0.0.1/remote.php/carddav/addressbooks/asdf/'
|
url += '/remote.php/carddav/addressbooks/asdf/'
|
||||||
else:
|
else:
|
||||||
url = 'http://127.0.0.1/remote.php/carddav/addressbooks/asdf/'
|
url += '/remote.php/carddav/addressbooks/asdf/'
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
|
# the following collections are setup in ownCloud
|
||||||
assert collection in ('test', 'test1', 'test2', 'test3', 'test4',
|
assert collection in ('test', 'test1', 'test2', 'test3', 'test4',
|
||||||
'test5', 'test6', 'test7', 'test8', 'test9',
|
'test5', 'test6', 'test7', 'test8', 'test9',
|
||||||
'test10')
|
'test10')
|
||||||
|
|
||||||
return {'url': url, 'collection': collection}
|
return {'url': url, 'collection': collection, 'username': 'asdf', 'password': 'asdf'}
|
||||||
|
|
||||||
def teardown_method(self, method):
|
|
||||||
if self.wsgi_teardown is not None:
|
|
||||||
self.wsgi_teardown()
|
|
||||||
self.wsgi_teardown = None
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue