Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tentative multi-db testing strategy

  • Loading branch information...
commit 873ac1f52f88ca053e684e7a4f4913097e940f8f 1 parent f2f44b0
@yakky yakky authored
Showing with 41 additions and 10 deletions.
  1. +26 −7 cms/test_utils/cli.py
  2. +15 −3 runtests.py
View
33 cms/test_utils/cli.py
@@ -8,19 +8,39 @@
urlpatterns = []
DJANGO_1_3 = LooseVersion(django.get_version()) < LooseVersion('1.4')
-def configure(**extra):
+def configure(db_data,**extra):
from django.conf import settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'cms.test_utils.cli'
+ db_type = db_data.get('DB','sqlite')
+ if db_type == 'sqlite':
+ DB = {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ }
+ elif db_type == 'postgres':
+ DB = {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': db_data.get('NAME', 'djangocms'),
+ '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'),
+ 'USER': db_data.get('USER', 'root'),
+ }
+ if db_data.get('PASSWORD', None):
+ DB['PASSWORD'] = db_data['PASSWORD']
+
defaults = dict(
CACHE_BACKEND = 'locmem:///',
DEBUG = True,
TEMPLATE_DEBUG = True,
DATABASE_SUPPORTS_TRANSACTIONS = True,
DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': ':memory:',
- }
+ 'default': DB
},
SITE_ID = 1,
USE_I18N = True,
@@ -222,7 +242,6 @@ def configure(**extra):
from django.utils.functional import empty
settings._wrapped = empty
defaults.update(extra)
-
settings.configure(**defaults)
from cms.conf import patch_settings
patch_settings()
@@ -231,4 +250,4 @@ def configure(**extra):
from django.contrib import admin
- admin.autodiscover()
+ admin.autodiscover()
View
18 runtests.py
@@ -7,12 +7,12 @@
def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir='.',
- time_tests=False, verbosity=1, failfast=False, test_labels=None):
+ time_tests=False, verbosity=1, failfast=False, test_labels=None,db_data={}):
if not test_labels:
test_labels = ['cms']
with temp_dir() as STATIC_ROOT:
with temp_dir() as MEDIA_ROOT:
- configure(TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
+ configure(db_data=db_data,TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
TIME_TESTS=time_tests, ROOT_URLCONF='cms.test_utils.project.urls',
STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT)
from django.conf import settings
@@ -36,6 +36,10 @@ def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir
parser.add_argument('--verbosity', default=1)
parser.add_argument('--time-tests', action='store_true', default=False,
dest='time_tests')
+ 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('test_labels', nargs='*')
args = parser.parse_args()
if getattr(args, 'jenkins', False):
@@ -45,6 +49,14 @@ def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir
junit_output_dir = getattr(args, 'jenkins_data_dir', '.')
time_tests = getattr(args, 'time_tests', False)
test_labels = ['cms.%s' % label for label in args.test_labels]
+ db_data = {'DB':args.db}
+ if args.db_user:
+ db_data['USER'] = args.db_user
+ if args.db_name:
+ db_data['NAME'] = args.db_name
+ if args.db_password:
+ db_data['PASSWORD'] = args.db_password
main(test_runner=test_runner, junit_output_dir=junit_output_dir, time_tests=time_tests,
- verbosity=args.verbosity, failfast=args.failfast, test_labels=test_labels)
+ verbosity=args.verbosity, failfast=args.failfast, test_labels=test_labels,
+ db_data=db_data)
Please sign in to comment.
Something went wrong with that request. Please try again.