Made tests.settings like a real settings file

pull/391/head
Karl Hobley 2014-06-30 15:08:09 +01:00
rodzic c1dcb09a4f
commit 055b2e97e5
3 zmienionych plików z 98 dodań i 89 usunięć

Wyświetl plik

@ -31,11 +31,7 @@ sys.path.insert(0, os.path.abspath('..'))
# Autodoc may need to import some models modules which require django settings
# be configured
from django.conf import settings
if not settings.configured:
from wagtail.tests.settings import SETTINGS
settings.configure(**SETTINGS)
os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
# -- General configuration ------------------------------------------------

Wyświetl plik

@ -6,11 +6,10 @@ import shutil
from django.conf import settings
from django.core.management import execute_from_command_line
from wagtail.tests.settings import SETTINGS, STATIC_ROOT, MEDIA_ROOT
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
if not settings.configured:
settings.configure(**SETTINGS)
os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
def runtests():

Wyświetl plik

@ -7,11 +7,93 @@ WAGTAIL_ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(WAGTAIL_ROOT, 'test-static')
MEDIA_ROOT = os.path.join(WAGTAIL_ROOT, 'test-media')
try:
import elasticsearch
has_elasticsearch = True
except ImportError:
has_elasticsearch = False
DATABASES = {
'default': {
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.postgresql_psycopg2'),
'NAME': 'wagtaildemo',
'USER': os.environ.get('DATABASE_USER', 'postgres'),
}
}
SECRET_KEY = 'not needed'
ROOT_URLCONF='wagtail.tests.urls'
STATIC_URL = '/static/'
STATIC_ROOT = STATIC_ROOT
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
MEDIA_ROOT=MEDIA_ROOT
USE_TZ = True
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'django.core.context_processors.request',
)
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',
)
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.auth',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'taggit',
'south',
'compressor',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailredirects',
'wagtail.wagtailforms',
'wagtail.contrib.wagtailstyleguide',
'wagtail.tests',
]
# 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.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache',
}
}
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher', # don't use the intentionally slow default password hasher
)
COMPRESS_ENABLED = False # disable compression so that we can run tests on the content of the compress tag
LOGIN_REDIRECT_URL = 'wagtailadmin_home'
LOGIN_URL = 'wagtailadmin_login'
WAGTAILSEARCH_BACKENDS = {
'default': {
@ -19,86 +101,18 @@ WAGTAILSEARCH_BACKENDS = {
}
}
if has_elasticsearch:
try:
# Only add Elasticsearch backend if the elasticsearch-py library is installed
import elasticsearch
# Import succeeded, add an Elasticsearch backend
WAGTAILSEARCH_BACKENDS['elasticsearch'] = {
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
'TIMEOUT': 10,
'max_retries': 1,
}
except ImportError:
pass
SETTINGS = dict(
DATABASES={
'default': {
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.postgresql_psycopg2'),
'NAME': 'wagtaildemo',
'USER': os.environ.get('DATABASE_USER', 'postgres'),
}
},
ROOT_URLCONF='wagtail.tests.urls',
STATIC_URL='/static/',
STATIC_ROOT=STATIC_ROOT,
MEDIA_ROOT=MEDIA_ROOT,
USE_TZ=True,
STATICFILES_FINDERS=(
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
),
TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'django.core.context_processors.request',
),
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',
),
INSTALLED_APPS=[
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.auth',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'taggit',
'south',
'compressor',
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailredirects',
'wagtail.wagtailforms',
'wagtail.contrib.wagtailstyleguide',
'wagtail.tests',
],
# 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.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache',
}
},
PASSWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PasswordHasher', # don't use the intentionally slow default password hasher
),
COMPRESS_ENABLED=False, # disable compression so that we can run tests on the content of the compress tag
WAGTAILSEARCH_BACKENDS=WAGTAILSEARCH_BACKENDS,
WAGTAIL_SITE_NAME='Test Site',
LOGIN_REDIRECT_URL='wagtailadmin_home',
LOGIN_URL='wagtailadmin_login',
)
WAGTAIL_SITE_NAME = "Test Site"