Skip to content

Commit 3cdcd79

Browse files
committed
Multi database engine tests
1 parent 1a7e248 commit 3cdcd79

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@ python:
77
env:
88
- DJANGO=1.7
99
- DJANGO=1.8
10+
- DATABASE_ENGINE=sqlite
11+
- DATABASE_ENGINE=postgres
12+
- DATABASE_ENGINE=mysql
1013
matrix:
1114
fast_finish: true
1215
install:
1316
- pip install -U setuptools
1417
- python bootstrap.py
1518
- ./bin/buildout versions:django=$DJANGO
19+
- sh -c "if [ '$DATABASE_ENGINE' = 'postgres' ];
20+
then
21+
pip install psycopg2;
22+
psql -c 'create database tagging;' -U postgres;
23+
fi"
24+
- sh -c "if [ '$DATABASE_ENGINE' = 'mysql' ];
25+
then
26+
pip install mysql-python;
27+
mysql -e 'create database tagging CHARACTER SET utf8 COLLATE utf8_general_ci;';
28+
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql;
29+
fi"
1630
before_script:
1731
- ./bin/flake8 tagging
1832
script:

tagging/tests/settings.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests settings"""
2+
import os
23

34
SECRET_KEY = 'secret-key'
45

@@ -9,6 +10,26 @@
910
}
1011
}
1112

13+
DATABASE_ENGINE = os.environ.get('DATABASE_ENGINE')
14+
if DATABASE_ENGINE == 'postgres':
15+
DATABASES = {
16+
'default': {
17+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
18+
'NAME': 'tagging',
19+
'USER': 'postgres',
20+
'HOST': 'localhost'
21+
}
22+
}
23+
elif DATABASE_ENGINE == 'mysql':
24+
DATABASES = {
25+
'default': {
26+
'ENGINE': 'django.db.backends.mysql',
27+
'NAME': 'zinnia',
28+
'USER': 'root',
29+
'HOST': 'localhost'
30+
}
31+
}
32+
1233
INSTALLED_APPS = [
1334
'django.contrib.auth',
1435
'django.contrib.sessions',

0 commit comments

Comments
 (0)