Skip to content

Commit

Permalink
Merge pull request #54 from Tivix/multiple-db-tests
Browse files Browse the repository at this point in the history
Multiple db tests
  • Loading branch information
mjaworski committed Apr 27, 2015
2 parents dab0263 + 22c1052 commit cbd0091
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 18 deletions.
13 changes: 10 additions & 3 deletions .travis.yml
Expand Up @@ -3,8 +3,14 @@ python:
- "2.7"
- "3.4"
env:
- DJANGO=1.7.7
- DJANGO=1.8
- DJANGO=1.7.7 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.8 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.7.7 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.8 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.7.7 DJANGO_SETTINGS_MODULE='settings_mysql'
- DJANGO=1.8 DJANGO_SETTINGS_MODULE='settings_mysql'
addons:
- postgresql: "9.3"
install:
- pip install -q Django==$DJANGO --use-mirrors
- pip install coveralls
Expand All @@ -14,4 +20,5 @@ script:
after_success:
- coveralls
before_script:
- mysql -e 'create database djangocron;'
- mysql -e 'create database travis_test;'
- psql -c 'create database travis_test;' -U postgres
2 changes: 1 addition & 1 deletion django_cron/tests.py
Expand Up @@ -19,7 +19,7 @@ class TestCase(unittest.TestCase):
error_cron = 'test_crons.TestErrorCronJob'
five_mins_cron = 'test_crons.Test5minsCronJob'
run_at_times_cron = 'test_crons.TestRunAtTimesCronJob'
wait_3sec_cron = 'test_crons.Wiat3secCronJob'
wait_3sec_cron = 'test_crons.Wait3secCronJob'
test_failed_runs_notification_cron = 'django_cron.cron.FailedRunsNotificationCronJob'

def setUp(self):
Expand Down
6 changes: 4 additions & 2 deletions runtests.py
Expand Up @@ -2,7 +2,9 @@
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
if 'DJANGO_SETTINGS_MODULE' not in os.environ:
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'

test_dir = os.path.dirname(__file__)
sys.path.insert(0, test_dir)

Expand All @@ -13,7 +15,7 @@

def runtests():
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True)
test_runner = TestRunner(verbosity=1, interactive=False)
if hasattr(django, 'setup'):
django.setup()
failures = test_runner.run_tests(['django_cron'])
Expand Down
12 changes: 1 addition & 11 deletions test_settings.py → settings_base.py
@@ -1,13 +1,3 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'USER': 'travis',
'NAME': 'djangocron',
'TEST_NAME': 'djangocron_test',
}
}

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
Expand All @@ -29,7 +19,7 @@
'test_crons.TestErrorCronJob',
'test_crons.Test5minsCronJob',
'test_crons.TestRunAtTimesCronJob',
'test_crons.Wiat3secCronJob',
'test_crons.Wait3secCronJob',
'django_cron.cron.FailedRunsNotificationCronJob'
]

Expand Down
11 changes: 11 additions & 0 deletions settings_mysql.py
@@ -0,0 +1,11 @@
from settings_base import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER': 'travis',
'PASSWORD': '',
'NAME': 'travis',
'TEST_NAME': 'travis_test',
}
}
11 changes: 11 additions & 0 deletions settings_postgres.py
@@ -0,0 +1,11 @@
from settings_base import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres',
'PASSWORD': '',
'NAME': 'travis',
'TEST_NAME': 'travis_test',
}
}
10 changes: 10 additions & 0 deletions settings_sqllite.py
@@ -0,0 +1,10 @@
from settings_base import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'USER': 'travis',
'NAME': 'djangocron',
'TEST_NAME': 'djangocron_test',
}
}
2 changes: 1 addition & 1 deletion test_crons.py
Expand Up @@ -35,7 +35,7 @@ def do(self):
pass


class Wiat3secCronJob(CronJobBase):
class Wait3secCronJob(CronJobBase):
code = 'test_wait_3_seconds'
schedule = Schedule(run_every_mins=5)

Expand Down
2 changes: 2 additions & 0 deletions test_requirements.pip
@@ -1 +1,3 @@
freezegun==0.2.8
mysqlclient==1.3.6
psycopg2==2.6

0 comments on commit cbd0091

Please sign in to comment.