From 39d57003d35d6b82db1c67ed2a618d6c89989d27 Mon Sep 17 00:00:00 2001 From: ZuluPro Date: Sat, 30 Jul 2016 13:35:58 -0400 Subject: [PATCH] Added functional tests for mongodb --- .travis.yml | 30 ++++++++++++++++-------------- dbbackup/tests/settings.py | 18 ++++++++++++++++-- tox.ini | 11 ++++++++--- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae709e92..dcd9cec5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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} @@ -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 diff --git a/dbbackup/tests/settings.py b/dbbackup/tests/settings.py index 5d194add..cb7061cd 100644 --- a/dbbackup/tests/settings.py +++ b/dbbackup/tests/settings.py @@ -3,6 +3,10 @@ """ import os import tempfile +try: + from urlparse import urlparse +except ImportError: + from urllib.parse import urlparse import dj_database_url @@ -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 = { diff --git a/tox.ini b/tox.ini index a047788f..53499a52 100644 --- a/tox.ini +++ b/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 = * @@ -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}