Skip to content

Commit

Permalink
Added functional tests for mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuluPro committed Jul 30, 2016
1 parent 56f4e91 commit 39d5700
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
30 changes: 16 additions & 14 deletions .travis.yml
Expand Up @@ -2,12 +2,12 @@ language: python

python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
- "pypy3"
# - "3.2"
# - "3.3"
# - "3.4"
# - "3.5"
# - "pypy"
# - "pypy3"

services:
- mysql
Expand All @@ -18,11 +18,11 @@ addons:

env:
matrix:
- DJANGO=1.6
- DJANGO=1.7
- DJANGO=1.8
- DJANGO=1.9
- DJANGO=1.10
# - DJANGO=1.6
# - DJANGO=1.7
# - DJANGO=1.8
- DJANGO=1.9
# - DJANGO=1.10

install:
- TOX_ENV=py${TRAVIS_PYTHON_VERSION}-django${DJANGO}
Expand Down Expand Up @@ -55,10 +55,12 @@ matrix:
before_install:
- mysql -e 'CREATE DATABASE test;'
- psql -c 'CREATE DATABASE test;' -U postgres
- mongo mydb_test --eval 'db.addUser("travis", "test");'
script:
- DATABASE_URL=sqlite:////tmp/db.sqlite tox -e functional
- DATABASE_URL=mysql://travis:@localhost/test tox -e functional
- DATABASE_URL=postgres://postgres:@localhost/test tox -e functional
# - DATABASE_URL=sqlite:////tmp/db.sqlite tox -e functional
# - DATABASE_URL=mysql://travis:@localhost/test tox -e functional
# - DATABASE_URL=postgres://postgres:@localhost/test tox -e functional
- DATABASE_URL=mongodb://travis:test@localhost/mydb_test tox -e functional-py2.7-django1.9-mongodb
exclude:
- python: "3.5"
env: DJANGO=1.6
Expand Down
18 changes: 16 additions & 2 deletions dbbackup/tests/settings.py
Expand Up @@ -3,6 +3,10 @@
"""
import os
import tempfile
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
import dj_database_url


Expand All @@ -22,8 +26,18 @@
'dbbackup.tests.testapp',
)

DATABASE = dj_database_url.config(default='sqlite:///%s' %
tempfile.mktemp())
if os.environ.get('DATABASE_URL', '').startswith('mongodb://'):
parser = urlparse(os.environ['DATABASE_URL'])
DATABASE = {
'ENGINE': 'django_mongodb_engine.engine',
'NAME': parser.path.replace('/', ''),
'HOST': parser.hostname,
'USER': parser.username,
'PASSWORD': parser.password,
}
else:
DATABASE = dj_database_url.config(default='sqlite:///%s' %
tempfile.mktemp())
DATABASES = {'default': DATABASE}

CACHES = {
Expand Down
11 changes: 8 additions & 3 deletions tox.ini
@@ -1,5 +1,9 @@
[tox]
envlist = py{2.7,3.2,3.3,3.4,3.5,pypy,pypy3}-django{1.6,1.7,1.8,1.9,1.10},lint,docs,functional
envlist =
py{2.7,3.2,3.3,3.4,3.5,pypy,pypy3}-django{1.6,1.7,1.8,1.9,1.10}
lint
docs
functional-py{2.7,3.2,3.3,3.4,3.5,pypy,pypy3}-django{1.6,1.7,1.8,1.9,1.10}-{mysql,postgresql,mongodb}

[testenv]
passenv = *
Expand Down Expand Up @@ -38,7 +42,8 @@ whitelist_externals = bash
deps =
-rrequirements-tests.txt
Django
mysqlclient
psycopg2
mysql: mysqlclient
postgresql: psycopg2
mongodb: django-mongodb-engine
basepython = python
commands = {posargs:bash -x functional.sh}

0 comments on commit 39d5700

Please sign in to comment.