forked from jazzband/django-waffle
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_settings.py
110 lines (92 loc) · 2.71 KB
/
test_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import os
import django
from distutils.version import StrictVersion
DJANGO_VERSION = StrictVersion(django.get_version())
# Make filepaths relative to settings.
ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)
DEBUG = True
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
JINJA_CONFIG = {}
SITE_ID = 1
USE_I18N = False
SECRET_KEY = 'foobar'
DATABASES = {
'default': {
'NAME': 'test.db',
'ENGINE': 'django.db.backends.sqlite3',
},
# Provide a readonly DB for testing DB replication scenarios.
'readonly': {
'NAME': 'test.readonly.db',
'ENGINE': 'django.db.backends.sqlite3',
}
}
if 'DATABASE_URL' in os.environ:
try:
import dj_database_url
import psycopg2
DATABASES['default'] = dj_database_url.config()
except ImportError:
raise ImportError('Using the DATABASE_URL variable requires '
'dj-database-url and psycopg2. Try:\n\npip install '
'-r travis.txt')
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'waffle',
'test_app',
)
_MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'waffle.middleware.WaffleMiddleware',
)
if DJANGO_VERSION < StrictVersion('1.10.0'):
MIDDLEWARE_CLASSES = _MIDDLEWARE_CLASSES
else:
MIDDLEWARE = _MIDDLEWARE_CLASSES
ROOT_URLCONF = 'test_app.urls'
CUSTOM_USER_MODEL = 'auth.User'
_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.request',
)
TEMPLATES = [
{
'BACKEND': 'django_jinja.backend.Jinja2',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'match_regex': r'jinja.*',
'match_extension': '',
'newstyle_gettext': True,
'context_processors': _CONTEXT_PROCESSORS,
'undefined': 'jinja2.Undefined',
'extensions': [
'jinja2.ext.i18n',
'jinja2.ext.autoescape',
'waffle.jinja.WaffleExtension',
],
}
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'debug': DEBUG,
'context_processors': _CONTEXT_PROCESSORS,
}
},
]
WAFFLE_FLAG_DEFAULT = False
WAFFLE_SWITCH_DEFAULT = False
WAFFLE_SAMPLE_DEFAULT = False
WAFFLE_READ_FROM_WRITE_DB = False
WAFFLE_OVERRIDE = False
WAFFLE_CACHE_PREFIX = 'test:'