Test radicale with docker too

This commit is contained in:
Hugo Osvaldo Barrera 2020-06-08 20:58:16 +02:00
parent 0f3b2e74c0
commit b0d8fd34dc
4 changed files with 22 additions and 58 deletions

View file

@ -5,3 +5,8 @@ services:
build: docker/xandikos/
ports:
- '8000:8000'
radicale:
build: docker/radicale/
ports:
- '8001:8001'

View file

@ -0,0 +1,5 @@
FROM python:3.8
RUN pip install radicale
CMD radicale --storage-filesystem-folder /tmp/dav -H 0.0.0.0:8001 -D

View file

@ -1,57 +1,19 @@
import logging
import pytest
import radicale
import radicale.config
from pkg_resources import parse_version as ver
import wsgi_intercept
import wsgi_intercept.requests_intercept
logger = logging.getLogger(__name__)
class ServerMixin:
@pytest.fixture(autouse=True)
def setup(self, request, tmpdir):
if ver(radicale.VERSION) < ver('2.0.0-pre'):
raise RuntimeError('Testing against Radicale only works with '
'Radicale >= 2.0.0')
def get_app():
config = radicale.config.load(())
config.set('storage', 'filesystem_folder', str(tmpdir))
config.set('rights', 'type', 'owner_only')
app = radicale.Application(config, logger)
def is_authenticated(user, password):
return user == 'bob' and password == 'bob'
app.is_authenticated = is_authenticated
return app
wsgi_intercept.requests_intercept.install()
wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_app)
def teardown():
wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 80)
wsgi_intercept.requests_intercept.uninstall()
request.addfinalizer(teardown)
@pytest.fixture
def get_storage_args(self, get_item):
def inner(collection='test'):
url = 'http://127.0.0.1/'
rv = {'url': url, 'username': 'bob', 'password': 'bob'}
def get_storage_args(self, request, tmpdir, slow_create_collection):
def inner(collection="test"):
url = "http://127.0.0.1:8001/"
args = {
"url": url,
"username": "radicale",
"password": "radicale",
}
if collection is not None:
collection = collection + self.storage_class.fileext
rv = self.storage_class.create_collection(collection, **rv)
s = self.storage_class(**rv)
assert not list(s.list())
args = slow_create_collection(self.storage_class, args, collection)
return args
return rv
return inner

View file

@ -1,12 +1,4 @@
#!/bin/sh
set -e
if [ "$REQUIREMENTS" = "release" ] || [ "$REQUIREMENTS" = "minimal" ]; then
radicale_pkg="radicale==2.1.10"
elif [ "$REQUIREMENTS" = "devel" ]; then
radicale_pkg="git+https://github.com/Kozea/Radicale.git"
else
echo "Invalid requirements envvar"
false
fi
pip install wsgi_intercept $radicale_pkg
docker-compose build radicale
docker-compose up -d radicale