2014-02-13 13:44:49 +01:00
|
|
|
#!/usr/bin/env python
|
2014-02-17 12:03:41 +01:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import shutil
|
2014-02-13 13:44:49 +01:00
|
|
|
|
|
|
|
from django.conf import settings, global_settings
|
|
|
|
from django.core.management import execute_from_command_line
|
|
|
|
|
|
|
|
WAGTAIL_ROOT = os.path.dirname(__file__)
|
|
|
|
STATIC_ROOT = os.path.join(WAGTAIL_ROOT, 'test-static')
|
2014-02-23 15:57:33 +01:00
|
|
|
MEDIA_ROOT = os.path.join(WAGTAIL_ROOT, 'test-media')
|
2014-02-13 13:44:49 +01:00
|
|
|
|
|
|
|
if not settings.configured:
|
2014-03-03 13:33:14 +01:00
|
|
|
|
|
|
|
try:
|
2014-04-05 21:10:58 +02:00
|
|
|
import elasticsearch
|
2014-03-03 13:33:14 +01:00
|
|
|
has_elasticsearch = True
|
|
|
|
except ImportError:
|
|
|
|
has_elasticsearch = False
|
|
|
|
|
|
|
|
WAGTAILSEARCH_BACKENDS = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'wagtail.wagtailsearch.backends.db.DBSearch',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if has_elasticsearch:
|
|
|
|
WAGTAILSEARCH_BACKENDS['elasticsearch'] = {
|
|
|
|
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
|
2014-05-28 13:05:35 +02:00
|
|
|
'TIMEOUT': 10,
|
|
|
|
'max_retries': 1,
|
2014-03-03 13:33:14 +01:00
|
|
|
}
|
|
|
|
|
2014-02-13 13:44:49 +01:00
|
|
|
settings.configure(
|
|
|
|
DATABASES={
|
|
|
|
'default': {
|
2014-04-24 16:34:59 +02:00
|
|
|
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.postgresql_psycopg2'),
|
2014-02-13 13:44:49 +01:00
|
|
|
'NAME': 'wagtaildemo',
|
2014-05-01 13:21:17 +02:00
|
|
|
'USER': os.environ.get('DATABASE_USER', 'postgres'),
|
2014-02-13 13:44:49 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
ROOT_URLCONF='wagtail.tests.urls',
|
|
|
|
STATIC_URL='/static/',
|
|
|
|
STATIC_ROOT=STATIC_ROOT,
|
2014-02-23 15:57:33 +01:00
|
|
|
MEDIA_ROOT=MEDIA_ROOT,
|
2014-05-28 17:27:53 +02:00
|
|
|
USE_TZ=True,
|
2014-02-17 12:03:41 +01:00
|
|
|
STATICFILES_FINDERS=(
|
2014-02-13 13:44:49 +01:00
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
|
|
'compressor.finders.CompressorFinder',
|
|
|
|
),
|
|
|
|
TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
|
|
|
'django.core.context_processors.request',
|
|
|
|
),
|
2014-02-14 18:17:31 +01:00
|
|
|
MIDDLEWARE_CLASSES=(
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
|
|
|
|
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
|
|
|
|
|
|
|
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
|
|
|
),
|
2014-02-13 13:44:49 +01:00
|
|
|
INSTALLED_APPS=[
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2014-02-18 10:22:51 +01:00
|
|
|
'django.contrib.admin',
|
2014-02-13 13:44:49 +01:00
|
|
|
|
|
|
|
'taggit',
|
|
|
|
'south',
|
|
|
|
'compressor',
|
|
|
|
|
|
|
|
'wagtail.wagtailcore',
|
|
|
|
'wagtail.wagtailadmin',
|
|
|
|
'wagtail.wagtaildocs',
|
|
|
|
'wagtail.wagtailsnippets',
|
|
|
|
'wagtail.wagtailusers',
|
|
|
|
'wagtail.wagtailimages',
|
|
|
|
'wagtail.wagtailembeds',
|
|
|
|
'wagtail.wagtailsearch',
|
|
|
|
'wagtail.wagtailredirects',
|
2014-05-07 17:39:56 +02:00
|
|
|
'wagtail.wagtailforms',
|
2014-06-11 10:48:07 +02:00
|
|
|
'wagtail.contrib.wagtailstyleguide',
|
2014-02-20 22:32:51 +01:00
|
|
|
'wagtail.tests',
|
2014-02-21 23:15:35 +01:00
|
|
|
],
|
2014-05-02 13:33:20 +02:00
|
|
|
|
|
|
|
# Using DatabaseCache to make sure that the cache is cleared between tests.
|
|
|
|
# This prevents false-positives in some wagtail core tests where we are
|
|
|
|
# changing the 'wagtail_root_paths' key which may cause future tests to fail.
|
2014-05-02 12:45:31 +02:00
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
|
|
|
'LOCATION': 'cache',
|
|
|
|
}
|
|
|
|
},
|
2014-03-04 16:47:16 +01:00
|
|
|
PASSWORD_HASHERS=(
|
|
|
|
'django.contrib.auth.hashers.MD5PasswordHasher', # don't use the intentionally slow default password hasher
|
|
|
|
),
|
2014-04-04 16:50:39 +02:00
|
|
|
COMPRESS_ENABLED=False, # disable compression so that we can run tests on the content of the compress tag
|
2014-03-03 13:33:14 +01:00
|
|
|
WAGTAILSEARCH_BACKENDS=WAGTAILSEARCH_BACKENDS,
|
2014-06-02 14:41:00 +02:00
|
|
|
WAGTAIL_SITE_NAME='Test Site',
|
2014-06-16 11:31:05 +02:00
|
|
|
LOGIN_REDIRECT_URL='wagtailadmin_home',
|
2014-06-06 13:52:00 +02:00
|
|
|
LOGIN_URL='wagtailadmin_login',
|
2014-02-13 13:44:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def runtests():
|
|
|
|
argv = sys.argv[:1] + ['test'] + sys.argv[1:]
|
2014-02-13 13:53:52 +01:00
|
|
|
try:
|
|
|
|
execute_from_command_line(argv)
|
|
|
|
finally:
|
|
|
|
shutil.rmtree(STATIC_ROOT, ignore_errors=True)
|
2014-02-23 15:57:33 +01:00
|
|
|
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
|
2014-02-13 13:44:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
runtests()
|