Skip to content
Browse files

multi db testing

  • Loading branch information...
1 parent 8bfcd6f commit 5a6c356f05a8bd5fd26c71686398ee2ae436280e @digi604 committed Nov 14, 2012
Showing with 25 additions and 14 deletions.
  1. +15 −3 .travis.yml
  2. +2 −2 cms/test_utils/cli.py
  3. +6 −1 runtests.py
  4. +2 −8 runtestserver.py
View
18 .travis.yml
@@ -4,12 +4,24 @@ python:
- "2.6"
- "2.7"
env:
- - DJANGO=test_requirements/django-1.3.txt
- - DJANGO=test_requirements/django-1.4.txt
+ - DJANGO=test_requirements/django-1.3.txt DB=sqlite
+ - DJANGO=test_requirements/django-1.3.txt DB=mysql
+ - DJANGO=test_requirements/django-1.3.txt DB=postgres
+ - DJANGO=test_requirements/django-1.4.txt DB=sqlite
+ - DJANGO=test_requirements/django-1.4.txt DB=mysql
+ - DJANGO=test_requirements/django-1.4.txt DB=postgres
+
+before_script:
+ - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS djangocms_test;' -U postgres; fi"
+ - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database djangocms_test;' -U postgres; fi"
+ - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS djangocms_test'; fi"
+
install:
+ - pip install mysql-python
+ - pip install psycopg2
- pip install -q -r $DJANGO --use-mirrors
script:
- python runtests.py
+ python runtests.py --db_name djangocms_test
notifications:
email:
recipients:
View
4 cms/test_utils/cli.py
@@ -20,15 +20,15 @@ def configure(db_data, **extra):
elif db_type == 'postgres':
DB = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
- 'NAME': db_data.get('NAME', 'djangocms'),
+ 'NAME': db_data.get('NAME', 'djangocms_test'),
'USER': db_data.get('USER', 'postgres'),
}
if db_data.get('PASSWORD', None):
DB['PASSWORD'] = db_data['PASSWORD']
elif db_type == 'mysql':
DB = {
'ENGINE': 'django.db.backends.mysql',
- 'NAME': db_data.get('NAME', 'djangocms'),
+ 'NAME': db_data.get('NAME', 'djangocms_test'),
'USER': db_data.get('USER', 'root'),
}
if db_data.get('PASSWORD', None):
View
7 runtests.py
@@ -45,7 +45,7 @@ def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir
parser.add_argument('--db', default='sqlite', dest='db')
parser.add_argument('--db_user', default=None, dest='db_user')
parser.add_argument('--db_name', default=None, dest='db_name')
- parser.add_argument('--db_password', default=None, dest='db_password')
+ parser.add_argument('--db_password', default="", dest='db_password')
parser.add_argument('test_labels', nargs='*')
args = parser.parse_args()
if getattr(args, 'jenkins', False):
@@ -58,6 +58,11 @@ def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir
db_data = {'DB':args.db}
if args.db_user:
db_data['USER'] = args.db_user
+ else:
+ if args.db == "mysql":
+ db_data['USER'] = "root"
+ elif args.db == 'postgres':
+ db_data['USER'] = 'postgres'
if args.db_name:
db_data['NAME'] = args.db_name
if args.db_password:
View
10 runtestserver.py
@@ -15,16 +15,10 @@ def main():
new_db = not os.path.exists('cmstestdb.sqlite')
with temp_dir() as STATIC_ROOT:
with temp_dir() as MEDIA_ROOT:
- configure(
+ configure({'DB':'sqlite'},
ROOT_URLCONF='cms.test_utils.project.urls',
STATIC_ROOT=STATIC_ROOT,
MEDIA_ROOT=MEDIA_ROOT,
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': 'cmstestdb.sqlite',
- }
- }
)
if os.environ.get("RUN_MAIN") != "true":
from django.core.management import call_command
@@ -51,7 +45,7 @@ def main():
rs._raw_ipv6 = False
rs.addr = args.bind
rs.port = args.port
- autoreload.main(rs.inner_run, (),{'addrport':'%s:%s' % (args.bind, args.port), 'insecure_serving':True, 'use_threading':True})
+ autoreload.main(rs.inner_run, (), {'addrport':'%s:%s' % (args.bind, args.port), 'insecure_serving':True, 'use_threading':True})
if __name__ == '__main__':
main()

0 comments on commit 5a6c356

Please sign in to comment.
Something went wrong with that request. Please try again.