diff --git a/.travis.sh b/.travis.sh index 4b22c3fc33..fd01fb8411 100755 --- a/.travis.sh +++ b/.travis.sh @@ -4,6 +4,16 @@ set -x echo "Executing job $1" +if [ "$PRETIX_CONFIG_FILE" == "tests/travis_mysql.cfg" ]; then + mysql -u root -e 'CREATE DATABASE pretix DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;' + pip3 install -Ur src/requirements/mysql.txt +fi + +if [ "$PRETIX_CONFIG_FILE" == "tests/travis_postgres.cfg" ]; then + psql -c 'create database travis_ci_test;' -U postgres + pip3 install -Ur src/requirements/postgres.txt +fi + if [ "$1" == "style" ]; then XDG_CACHE_HOME=/cache pip3 install -Ur src/requirements.txt -r src/requirements/dev.txt -r src/requirements/py34.txt cd src diff --git a/.travis.yml b/.travis.yml index 2a7c6588c0..20eb6bbfdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,38 @@ language: python sudo: false -python: - - "3.4" install: - - pip install -U pip wheel setuptools==28.6.1 + - pip install -U pip wheel setuptools==28.6.1 script: - - bash .travis.sh $JOB + - bash .travis.sh $JOB cache: - directories: - - $HOME/.cache/pip -env: - - JOB=style - - JOB=doctests - - JOB=tests-cov + directories: + - $HOME/.cache/pip +services: + - mysql + - postgresql +matrix: + include: + - python: 3.4 + env: JOB=tests PRETIX_CONFIG_FILE=tests/sqlite.cfg + - python: 3.5 + env: JOB=tests PRETIX_CONFIG_FILE=tests/sqlite.cfg + - python: 3.6 + env: JOB=tests PRETIX_CONFIG_FILE=tests/sqlite.cfg + - python: 3.4 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_mysql.cfg + - python: 3.5 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_mysql.cfg + - python: 3.6 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_mysql.cfg + - python: 3.4 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_postgres.cfg + - python: 3.5 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_postgres.cfg + - python: 3.6 + env: JOB=tests PRETIX_CONFIG_FILE=tests/travis_postgres.cfg + - python: 3.4 + env: JOB=style + - python: 3.4 + env: JOB=tests-cov +addons: + postgresql: "9.4" diff --git a/src/pretix/settings.py b/src/pretix/settings.py index e1854ad5ea..f1ee0494e5 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -10,8 +10,11 @@ from pkg_resources import iter_entry_points from . import __version__ config = configparser.RawConfigParser() -config.read(['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'], - encoding='utf-8') +if 'PRETIX_CONFIG_FILE' in os.environ: + config.read([os.environ.get('PRETIX_CONFIG_FILE')], encoding='utf-8') +else: + config.read(['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'], + encoding='utf-8') BASE_DIR = os.path.dirname(os.path.dirname(__file__)) DATA_DIR = config.get('pretix', 'datadir', fallback=os.environ.get('DATA_DIR', 'data')) diff --git a/src/pretix/testutils/settings.py b/src/pretix/testutils/settings.py index 967a69eedc..47b6e3901a 100644 --- a/src/pretix/testutils/settings.py +++ b/src/pretix/testutils/settings.py @@ -4,6 +4,7 @@ import tempfile tmpdir = tempfile.TemporaryDirectory() os.environ.setdefault('DATA_DIR', tmpdir.name) +os.environ.setdefault('PRETIX_CONFIG_FILE', 'test/sqlite.cfg') from pretix.settings import * # NOQA @@ -33,10 +34,3 @@ CACHES = { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } } - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:' - } -} diff --git a/src/tests/travis_mysql.cfg b/src/tests/travis_mysql.cfg new file mode 100644 index 0000000000..48dc3133ec --- /dev/null +++ b/src/tests/travis_mysql.cfg @@ -0,0 +1,7 @@ +[database] +backend=mysql +name=pretix +user=root +password= +host=127.0.0.1 +port=3306 diff --git a/src/tests/travis_postgres.cfg b/src/tests/travis_postgres.cfg new file mode 100644 index 0000000000..c2c635bc31 --- /dev/null +++ b/src/tests/travis_postgres.cfg @@ -0,0 +1,6 @@ +[database] +backend=postgresql_psycopg2 +name=pretix +user=postgres +password= +host=localhost