mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Flatten mysteryshack submodule
This commit is contained in:
parent
a02f36f0cb
commit
bb35d7c091
7 changed files with 104 additions and 4 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -4,9 +4,6 @@
|
|||
[submodule "tests/storage/servers/owncloud"]
|
||||
path = tests/storage/servers/owncloud
|
||||
url = https://github.com/vdirsyncer/owncloud-testserver
|
||||
[submodule "tests/storage/servers/mysteryshack"]
|
||||
path = tests/storage/servers/mysteryshack
|
||||
url = https://github.com/vdirsyncer/mysteryshack-testserver
|
||||
[submodule "tests/storage/servers/nextcloud"]
|
||||
path = tests/storage/servers/nextcloud
|
||||
url = https://github.com/vdirsyncer/nextcloud-testserver
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 8e501355582e072b5b9bf3b1d40ae8fa06e52eac
|
||||
1
tests/storage/servers/mysteryshack/.gitignore
vendored
Normal file
1
tests/storage/servers/mysteryshack/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
mysteryshack
|
||||
75
tests/storage/servers/mysteryshack/__init__.py
Normal file
75
tests/storage/servers/mysteryshack/__init__.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
import requests
|
||||
|
||||
testserver_repo = os.path.dirname(__file__)
|
||||
make_sh = os.path.abspath(os.path.join(testserver_repo, 'make.sh'))
|
||||
|
||||
|
||||
def wait():
|
||||
for i in range(100):
|
||||
try:
|
||||
requests.get('http://127.0.0.1:6767/', verify=False)
|
||||
except Exception as e:
|
||||
# Don't know exact exception class, don't care.
|
||||
# Also, https://github.com/kennethreitz/requests/issues/2192
|
||||
if 'connection refused' not in str(e).lower():
|
||||
raise
|
||||
time.sleep(2 ** i)
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class ServerMixin(object):
|
||||
@pytest.fixture(scope='session')
|
||||
def setup_mysteryshack_server(self, xprocess):
|
||||
def preparefunc(cwd):
|
||||
return wait, ['sh', make_sh, 'testserver']
|
||||
|
||||
subprocess.check_call(['sh', make_sh, 'testserver-config'])
|
||||
xprocess.ensure('mysteryshack_server', preparefunc)
|
||||
|
||||
return subprocess.check_output([
|
||||
os.path.join(
|
||||
testserver_repo,
|
||||
'mysteryshack/target/debug/mysteryshack'
|
||||
),
|
||||
'-c', '/tmp/mysteryshack/config',
|
||||
'user',
|
||||
'authorize',
|
||||
'testuser',
|
||||
'https://example.com',
|
||||
self.storage_class.scope + ':rw'
|
||||
]).strip().decode()
|
||||
|
||||
@pytest.fixture
|
||||
def get_storage_args(self, monkeypatch, setup_mysteryshack_server):
|
||||
from requests import Session
|
||||
|
||||
monkeypatch.setitem(os.environ, 'OAUTHLIB_INSECURE_TRANSPORT', 'true')
|
||||
|
||||
old_request = Session.request
|
||||
|
||||
def request(self, method, url, **kw):
|
||||
url = url.replace('https://', 'http://')
|
||||
return old_request(self, method, url, **kw)
|
||||
|
||||
monkeypatch.setattr(Session, 'request', request)
|
||||
shutil.rmtree('/tmp/mysteryshack/testuser/data', ignore_errors=True)
|
||||
shutil.rmtree('/tmp/mysteryshack/testuser/meta', ignore_errors=True)
|
||||
|
||||
def inner(**kw):
|
||||
kw['account'] = 'testuser@127.0.0.1:6767'
|
||||
kw['access_token'] = setup_mysteryshack_server
|
||||
if self.storage_class.fileext == '.ics':
|
||||
kw.setdefault('collection', 'test')
|
||||
return kw
|
||||
return inner
|
||||
18
tests/storage/servers/mysteryshack/install.sh
Normal file
18
tests/storage/servers/mysteryshack/install.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
set -ex
|
||||
cd "$(dirname "$0")"
|
||||
. ./variables.sh
|
||||
|
||||
if [ "$CI" = "true" ]; then
|
||||
curl -sL https://static.rust-lang.org/rustup.sh -o ~/rust-installer/rustup.sh
|
||||
sh ~/rust-installer/rustup.sh --prefix=~/rust --spec=stable -y --disable-sudo 2> /dev/null
|
||||
fi
|
||||
|
||||
if [ ! -d mysteryshack ]; then
|
||||
git clone https://github.com/untitaker/mysteryshack
|
||||
fi
|
||||
|
||||
pip install pytest-xprocess
|
||||
|
||||
cd mysteryshack
|
||||
make debug-build # such that first test doesn't hang too long w/o output
|
||||
9
tests/storage/servers/mysteryshack/make.sh
Normal file
9
tests/storage/servers/mysteryshack/make.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# pytest-xprocess doesn't allow us to CD into a particular directory before
|
||||
# launching a command, so we do it here.
|
||||
cd "$(dirname "$0")"
|
||||
. ./variables.sh
|
||||
cd mysteryshack
|
||||
exec make "$@"
|
||||
1
tests/storage/servers/mysteryshack/variables.sh
Normal file
1
tests/storage/servers/mysteryshack/variables.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
export PATH="$PATH:$HOME/.cargo/bin/"
|
||||
Loading…
Reference in a new issue