From a8702dae9665a5891399dfa6b0a3a03c68c3f46b Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Sun, 24 May 2020 14:15:34 +0200 Subject: [PATCH] Enable CI builds with postgresql and mysql --- .travis.yml | 10 ++++++++++ ihatemoney/tests/common/ihatemoney_testcase.py | 6 +++++- setup.cfg | 2 ++ tox.ini | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cc4db2b7..f2a01a1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,18 @@ python: - "3.7" - "3.8" - "3.9" +env: + - TESTING_SQLALCHEMY_DATABASE_URI='sqlite:///budget.db' + - TESTING_SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://postgres:@localhost/travis_ci_test' + - TESTING_SQLALCHEMY_DATABASE_URI='mysql+pymysql://travis:@localhost/travis_ci_test' +before_script: + - psql -c 'create database travis_ci_test;' -U postgres + - mysql -e 'CREATE DATABASE travis_ci_test;' script: tox before_install: - python -m pip install --upgrade pip virtualenv install: - pip install tox-travis +services: + - mysql + - postgresql diff --git a/ihatemoney/tests/common/ihatemoney_testcase.py b/ihatemoney/tests/common/ihatemoney_testcase.py index 2e590590..fed572a9 100644 --- a/ihatemoney/tests/common/ihatemoney_testcase.py +++ b/ihatemoney/tests/common/ihatemoney_testcase.py @@ -1,3 +1,5 @@ +import os + from flask_testing import TestCase from werkzeug.security import generate_password_hash @@ -58,7 +60,9 @@ class BaseTestCase(TestCase): class IhatemoneyTestCase(BaseTestCase): - SQLALCHEMY_DATABASE_URI = "sqlite://" + SQLALCHEMY_DATABASE_URI = os.environ.get( + "TESTING_SQLALCHEMY_DATABASE_URI", "sqlite://" + ) TESTING = True WTF_CSRF_ENABLED = False # Simplifies the tests. diff --git a/setup.cfg b/setup.cfg index 373b06da..4302c1bd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,6 +51,8 @@ dev = pytest>=5.4.1 tox>=3.14.6 zest.releaser>=6.20.1 + psycopg2-binary>=2.8.5 + PyMySQL>=0.9,<0.10 doc = Sphinx==4.0.2 diff --git a/tox.ini b/tox.ini index c358574d..f7817ef3 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py39,py38,py37,py36,lint_docs skip_missing_interpreters = True [testenv] +passenv = TESTING_SQLALCHEMY_DATABASE_URI commands = python --version