Test xandikos running it in docker

The main advantage here is that its dependencies are TOTALLY separate
from vdirsyncer's, keeping the runtime environment for vdirsyncer
cleaner.

It also makes testing locally not only possible, but fast and pleasant.
This commit is contained in:
Hugo Osvaldo Barrera 2020-06-08 20:26:19 +02:00
parent c410fbf331
commit 0f3b2e74c0
5 changed files with 29 additions and 38 deletions

7
docker-compose.yaml Normal file
View file

@ -0,0 +1,7 @@
version: '3'
services:
xandikos:
build: docker/xandikos/
ports:
- '8000:8000'

View file

@ -0,0 +1,13 @@
# Original file copyright 2017 Jelmer Vernooij
FROM ubuntu:bionic
RUN apt-get update && apt-get -y install xandikos locales
EXPOSE 8000
RUN locale-gen en_US.UTF-8
ENV PYTHONIOENCODING=utf-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
CMD xandikos -d /tmp/dav -l 0.0.0.0 -p 8000 --autocreate

View file

@ -10,7 +10,8 @@ addopts = --tb=short
# E743: Ambiguous function definition
ignore = E731, E743
# E503: Line break occurred before a binary operator
extend-ignore = W503
extend-ignore = E203, W503
max-line-length = 88
select = C,E,F,W,B,B9
exclude = .eggs, tests/storage/servers/owncloud/, tests/storage/servers/nextcloud/, tests/storage/servers/baikal/, build/
application-package-names = tests,vdirsyncer

View file

@ -1,35 +1,15 @@
import pytest
from xandikos.web import XandikosApp, XandikosBackend, WellknownRedirector
import wsgi_intercept
import wsgi_intercept.requests_intercept
class ServerMixin:
@pytest.fixture
def get_storage_args(self, request, tmpdir, slow_create_collection):
tmpdir.mkdir('xandikos')
backend = XandikosBackend(path=str(tmpdir))
cup = '/user/'
backend.create_principal(cup, create_defaults=True)
app = XandikosApp(backend, cup)
app = WellknownRedirector(app, '/')
wsgi_intercept.requests_intercept.install()
wsgi_intercept.add_wsgi_intercept('127.0.0.1', 8080, lambda: app)
def teardown():
wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 8080)
wsgi_intercept.requests_intercept.uninstall()
request.addfinalizer(teardown)
def inner(collection='test'):
url = 'http://127.0.0.1:8080/'
args = {'url': url, 'collection': collection}
def inner(collection="test"):
url = "http://127.0.0.1:8000/"
args = {"url": url}
if collection is not None:
args = self.storage_class.create_collection(**args)
args = slow_create_collection(self.storage_class, args, collection)
return args
return inner

View file

@ -1,14 +1,4 @@
#!/bin/sh
set -e
pip install wsgi_intercept
if [ "$REQUIREMENTS" = "release" ] || [ "$REQUIREMENTS" = "minimal" ]; then
# XXX: This is the last version to support Python 3.5
pip install -U "xandikos==0.0.11"
elif [ "$REQUIREMENTS" = "devel" ]; then
pip install -U git+https://github.com/jelmer/xandikos
else
echo "Invalid REQUIREMENTS value"
false
fi
docker-compose build xandikos
docker-compose up -d xandikos