2014-11-23 19:09:42 +00:00
|
|
|
|
import os
|
|
|
|
|
|
|
2021-05-13 04:27:14 +00:00
|
|
|
|
from django import VERSION as __DJ_V
|
|
|
|
|
|
|
2016-07-20 17:22:20 +00:00
|
|
|
|
|
2014-11-23 19:09:42 +00:00
|
|
|
|
DATABASES = {
|
|
|
|
|
|
'sqlite3': {
|
|
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
|
|
'NAME': 'cachalot.sqlite3',
|
|
|
|
|
|
},
|
|
|
|
|
|
'postgresql': {
|
2016-07-21 10:26:40 +00:00
|
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
2014-11-23 19:09:42 +00:00
|
|
|
|
'NAME': 'cachalot',
|
|
|
|
|
|
'USER': 'cachalot',
|
2023-03-12 20:39:50 +00:00
|
|
|
|
'PASSWORD': 'password',
|
2021-04-30 18:26:28 +00:00
|
|
|
|
'HOST': '127.0.0.1',
|
2014-11-23 19:09:42 +00:00
|
|
|
|
},
|
|
|
|
|
|
'mysql': {
|
|
|
|
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
|
|
|
|
'NAME': 'cachalot',
|
|
|
|
|
|
'USER': 'root',
|
2021-04-30 18:26:28 +00:00
|
|
|
|
'HOST': '127.0.0.1',
|
2014-11-23 19:09:42 +00:00
|
|
|
|
},
|
|
|
|
|
|
}
|
2018-05-04 14:19:57 +00:00
|
|
|
|
if 'MYSQL_PASSWORD' in os.environ:
|
|
|
|
|
|
DATABASES['mysql']['PASSWORD'] = os.environ['MYSQL_PASSWORD']
|
2021-04-30 18:26:28 +00:00
|
|
|
|
if 'POSTGRES_PASSWORD' in os.environ:
|
|
|
|
|
|
DATABASES['postgresql']['PASSWORD'] = os.environ['POSTGRES_PASSWORD']
|
2014-11-23 19:09:42 +00:00
|
|
|
|
for alias in DATABASES:
|
2016-09-13 18:15:30 +00:00
|
|
|
|
if 'TEST' not in DATABASES[alias]:
|
|
|
|
|
|
test_db_name = 'test_' + DATABASES[alias]['NAME']
|
|
|
|
|
|
DATABASES[alias]['TEST'] = {'NAME': test_db_name}
|
2014-11-23 19:09:42 +00:00
|
|
|
|
|
2014-12-07 02:43:16 +00:00
|
|
|
|
DATABASES['default'] = DATABASES.pop(os.environ.get('DB_ENGINE', 'sqlite3'))
|
2021-05-13 04:27:14 +00:00
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
2015-10-03 01:18:34 +00:00
|
|
|
|
DATABASE_ROUTERS = ['cachalot.tests.db_router.PostgresRouter']
|
|
|
|
|
|
|
2014-11-23 19:09:42 +00:00
|
|
|
|
CACHES = {
|
|
|
|
|
|
'redis': {
|
2014-12-07 05:32:19 +00:00
|
|
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
2014-12-13 18:56:34 +00:00
|
|
|
|
'LOCATION': 'redis://127.0.0.1:6379/0',
|
2014-12-07 05:37:24 +00:00
|
|
|
|
'OPTIONS': {
|
|
|
|
|
|
# Since we are using both Python 2 & 3 in tests, we need to use
|
|
|
|
|
|
# a compatible pickle version to avoid unpickling errors when
|
|
|
|
|
|
# running a Python 2 test after a Python 3 test.
|
|
|
|
|
|
'PICKLE_VERSION': 2,
|
2015-12-18 12:10:08 +00:00
|
|
|
|
},
|
2014-11-23 19:09:42 +00:00
|
|
|
|
},
|
|
|
|
|
|
'memcached': {
|
2021-05-13 04:27:14 +00:00
|
|
|
|
'BACKEND': 'django.core.cache.backends.memcached.'
|
|
|
|
|
|
+ ('PyMemcacheCache' if __DJ_V[0] > 2
|
|
|
|
|
|
and (__DJ_V[1] > 1 or __DJ_V[0] > 3) else 'MemcachedCache'),
|
2014-11-23 19:09:42 +00:00
|
|
|
|
'LOCATION': '127.0.0.1:11211',
|
|
|
|
|
|
},
|
2015-04-10 23:57:13 +00:00
|
|
|
|
'locmem': {
|
|
|
|
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
|
|
|
|
|
'OPTIONS': {
|
|
|
|
|
|
# We want that limit to be infinite, otherwise we can’t
|
|
|
|
|
|
# reliably count the number of SQL queries executed in tests.
|
|
|
|
|
|
|
|
|
|
|
|
# In this context, 10e9 is enough to be considered
|
|
|
|
|
|
# infinite.
|
|
|
|
|
|
'MAX_ENTRIES': 10e9,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'filebased': {
|
2014-12-14 07:08:51 +00:00
|
|
|
|
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
|
|
|
|
|
'LOCATION': '/tmp/django_cache',
|
|
|
|
|
|
'OPTIONS': {
|
|
|
|
|
|
'MAX_ENTRIES': 10e9, # (See locmem)
|
2015-12-18 12:10:08 +00:00
|
|
|
|
},
|
2014-12-14 07:08:51 +00:00
|
|
|
|
}
|
2015-04-10 23:57:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
import pylibmc
|
|
|
|
|
|
except ImportError:
|
|
|
|
|
|
pass
|
|
|
|
|
|
else:
|
|
|
|
|
|
CACHES['pylibmc'] = {
|
|
|
|
|
|
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
|
|
|
|
|
'LOCATION': '127.0.0.1:11211',
|
|
|
|
|
|
}
|
2014-12-07 02:43:16 +00:00
|
|
|
|
|
2014-12-14 07:08:51 +00:00
|
|
|
|
DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'locmem')
|
2014-12-08 02:47:11 +00:00
|
|
|
|
CACHES['default'] = CACHES.pop(DEFAULT_CACHE_ALIAS)
|
2014-12-08 04:00:52 +00:00
|
|
|
|
if DEFAULT_CACHE_ALIAS == 'memcached' and 'pylibmc' in CACHES:
|
2014-12-08 02:47:11 +00:00
|
|
|
|
del CACHES['pylibmc']
|
|
|
|
|
|
elif DEFAULT_CACHE_ALIAS == 'pylibmc':
|
|
|
|
|
|
del CACHES['memcached']
|
2014-12-07 02:43:16 +00:00
|
|
|
|
|
2014-11-23 19:09:42 +00:00
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
|
|
'cachalot',
|
2023-03-12 20:39:50 +00:00
|
|
|
|
'cachalot.admin_tests',
|
2014-11-23 19:09:42 +00:00
|
|
|
|
'django.contrib.auth',
|
|
|
|
|
|
'django.contrib.contenttypes',
|
2016-07-21 10:19:20 +00:00
|
|
|
|
'django.contrib.postgres', # Enables the unaccent lookup.
|
2023-03-12 20:39:50 +00:00
|
|
|
|
'django.contrib.sessions',
|
|
|
|
|
|
'django.contrib.admin',
|
|
|
|
|
|
'django.contrib.messages',
|
2014-11-23 19:09:42 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
2015-01-18 16:44:19 +00:00
|
|
|
|
MIGRATION_MODULES = {
|
2015-10-03 01:18:34 +00:00
|
|
|
|
'cachalot': 'cachalot.tests.migrations',
|
2015-01-18 16:44:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-07-21 08:57:06 +00:00
|
|
|
|
TEMPLATES = [
|
|
|
|
|
|
{
|
|
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
|
|
'DIRS': [],
|
|
|
|
|
|
'APP_DIRS': True,
|
2023-03-12 20:39:50 +00:00
|
|
|
|
'OPTIONS': {
|
|
|
|
|
|
'context_processors': [
|
|
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
|
|
],
|
|
|
|
|
|
}
|
2016-07-21 08:57:06 +00:00
|
|
|
|
},
|
2016-09-13 18:15:30 +00:00
|
|
|
|
{
|
|
|
|
|
|
'BACKEND': 'django.template.backends.jinja2.Jinja2',
|
|
|
|
|
|
'APP_DIRS': True,
|
|
|
|
|
|
'OPTIONS': {
|
|
|
|
|
|
'extensions': [
|
2016-09-13 18:30:18 +00:00
|
|
|
|
'cachalot.jinja2ext.cachalot',
|
2016-09-13 18:15:30 +00:00
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
2016-07-21 08:57:06 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
2023-03-12 20:39:50 +00:00
|
|
|
|
MIDDLEWARE = [
|
|
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
|
|
]
|
2016-10-23 18:06:58 +00:00
|
|
|
|
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
|
2016-09-13 18:15:30 +00:00
|
|
|
|
SECRET_KEY = 'it’s not important in tests but we have to set it'
|
2014-12-08 18:06:09 +00:00
|
|
|
|
|
2021-05-13 04:27:14 +00:00
|
|
|
|
USE_TZ = False # Time zones are not supported by MySQL, we only enable it in tests when needed.
|
2015-10-04 19:04:54 +00:00
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
2014-12-08 18:06:09 +00:00
|
|
|
|
CACHALOT_ENABLED = True
|
2016-10-23 18:06:58 +00:00
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
# Settings for django-debug-toolbar
|
|
|
|
|
|
#
|
|
|
|
|
|
|
2016-10-23 19:21:30 +00:00
|
|
|
|
# We put django-debug-toolbar before to reproduce the conditions of this issue:
|
2018-05-05 00:30:50 +00:00
|
|
|
|
# https://github.com/noripyt/django-cachalot/issues/62
|
2016-10-23 19:21:30 +00:00
|
|
|
|
INSTALLED_APPS = [
|
2016-10-23 18:06:58 +00:00
|
|
|
|
'debug_toolbar',
|
2016-10-23 19:21:30 +00:00
|
|
|
|
] + INSTALLED_APPS + ['django.contrib.staticfiles']
|
2016-10-23 18:06:58 +00:00
|
|
|
|
|
|
|
|
|
|
DEBUG_TOOLBAR_PANELS = [
|
|
|
|
|
|
'debug_toolbar.panels.versions.VersionsPanel',
|
|
|
|
|
|
'debug_toolbar.panels.timer.TimerPanel',
|
|
|
|
|
|
'debug_toolbar.panels.settings.SettingsPanel',
|
|
|
|
|
|
'debug_toolbar.panels.headers.HeadersPanel',
|
|
|
|
|
|
'debug_toolbar.panels.request.RequestPanel',
|
|
|
|
|
|
'debug_toolbar.panels.sql.SQLPanel',
|
|
|
|
|
|
'debug_toolbar.panels.staticfiles.StaticFilesPanel',
|
|
|
|
|
|
'debug_toolbar.panels.templates.TemplatesPanel',
|
|
|
|
|
|
'debug_toolbar.panels.cache.CachePanel',
|
|
|
|
|
|
'debug_toolbar.panels.signals.SignalsPanel',
|
|
|
|
|
|
'debug_toolbar.panels.logging.LoggingPanel',
|
|
|
|
|
|
'debug_toolbar.panels.redirects.RedirectsPanel',
|
|
|
|
|
|
'cachalot.panels.CachalotPanel',
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
|
|
|
|
# Django’s test client sets wsgi.multiprocess to True inappropriately.
|
|
|
|
|
|
'RENDER_PANELS': False,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-04 18:26:26 +00:00
|
|
|
|
MIDDLEWARE += [
|
2016-10-23 18:06:58 +00:00
|
|
|
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
INTERNAL_IPS = ['127.0.0.1']
|
|
|
|
|
|
ROOT_URLCONF = 'runtests_urls'
|
|
|
|
|
|
STATIC_URL = '/static/'
|