From a02f36f0cbbcb8fa1d55de5910c721ba3ced7ea9 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Wed, 8 Mar 2017 10:12:42 +0100 Subject: [PATCH] Flatten davical submodule --- .gitmodules | 3 -- tests/storage/servers/davical | 1 - tests/storage/servers/davical/__init__.py | 48 +++++++++++++++++++++++ tests/storage/servers/davical/install.sh | 1 + 4 files changed, 49 insertions(+), 4 deletions(-) delete mode 160000 tests/storage/servers/davical create mode 100644 tests/storage/servers/davical/__init__.py create mode 100644 tests/storage/servers/davical/install.sh diff --git a/.gitmodules b/.gitmodules index 9ad86bc..40aab99 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "tests/storage/servers/mysteryshack"] path = tests/storage/servers/mysteryshack url = https://github.com/vdirsyncer/mysteryshack-testserver -[submodule "tests/storage/servers/davical"] - path = tests/storage/servers/davical - url = https://github.com/vdirsyncer/davical-testserver [submodule "tests/storage/servers/nextcloud"] path = tests/storage/servers/nextcloud url = https://github.com/vdirsyncer/nextcloud-testserver diff --git a/tests/storage/servers/davical b/tests/storage/servers/davical deleted file mode 160000 index 24b4c72..0000000 --- a/tests/storage/servers/davical +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 24b4c72bd7be0dfb62a2e67f4a43e00544c3a96f diff --git a/tests/storage/servers/davical/__init__.py b/tests/storage/servers/davical/__init__.py new file mode 100644 index 0000000..c892ffd --- /dev/null +++ b/tests/storage/servers/davical/__init__.py @@ -0,0 +1,48 @@ +import os +import pytest +import uuid +import requests + +try: + caldav_args = { + # Those credentials are configured through the Travis UI + 'username': os.environ['DAVICAL_USERNAME'].strip(), + 'password': os.environ['DAVICAL_PASSWORD'].strip(), + 'url': 'https://brutus.lostpackets.de/davical-test/caldav.php/', + } +except KeyError as e: + pytestmark = pytest.mark.skip('Missing envkey: {}'.format(str(e))) + + +@pytest.mark.flaky(reruns=5) +class ServerMixin(object): + @pytest.fixture + def davical_args(self): + if self.storage_class.fileext == '.ics': + return dict(caldav_args) + elif self.storage_class.fileext == '.vcf': + pytest.skip('No carddav') + else: + raise RuntimeError() + + @pytest.fixture + def get_storage_args(self, davical_args, request): + def inner(collection='test'): + if collection is None: + return davical_args + + assert collection.startswith('test') + + for _ in range(4): + args = self.storage_class.create_collection( + collection + str(uuid.uuid4()), + **davical_args + ) + s = self.storage_class(**args) + if not list(s.list()): + request.addfinalizer( + lambda: s.session.request('DELETE', '')) + return args + + raise RuntimeError('Failed to find free collection.') + return inner diff --git a/tests/storage/servers/davical/install.sh b/tests/storage/servers/davical/install.sh new file mode 100644 index 0000000..c2af014 --- /dev/null +++ b/tests/storage/servers/davical/install.sh @@ -0,0 +1 @@ +pip install pytest-rerunfailures