django-constance/tests/settings.py

120 lines
3.6 KiB
Python
Raw Normal View History

from datetime import date
from datetime import datetime
from datetime import time
from datetime import timedelta
2010-09-03 12:38:43 +00:00
from decimal import Decimal
2025-10-07 09:25:07 +00:00
SECRET_KEY = "cheese"
MIDDLEWARE = (
2025-10-07 09:25:07 +00:00
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
2014-11-21 15:37:12 +00:00
)
2025-10-07 09:25:07 +00:00
DATABASE_ENGINE = "sqlite3"
2010-08-25 12:55:01 +00:00
DATABASES = {
2025-10-07 09:25:07 +00:00
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
},
2025-10-07 09:25:07 +00:00
"secondary": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
},
2010-08-25 12:55:01 +00:00
}
CACHES = {
"default": {
"BACKEND": "tests.cache_mockup.Cache",
"LOCATION": "locmem",
}
}
2010-08-25 12:55:01 +00:00
INSTALLED_APPS = (
2025-10-07 09:25:07 +00:00
"django.contrib.admin",
"django.contrib.staticfiles",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"constance",
"constance.backends.database",
2010-08-25 12:55:01 +00:00
)
2025-10-07 09:25:07 +00:00
ROOT_URLCONF = "tests.urls"
2010-11-12 14:06:59 +00:00
2025-10-07 09:25:07 +00:00
CONSTANCE_REDIS_CONNECTION_CLASS = "tests.redis_mockup.Connection"
CONSTANCE_REDIS_ASYNC_CONNECTION_CLASS = "tests.redis_mockup.AsyncConnection"
2010-08-25 13:08:07 +00:00
2015-06-14 15:25:56 +00:00
CONSTANCE_ADDITIONAL_FIELDS = {
2025-10-07 09:25:07 +00:00
"yes_no_null_select": [
"django.forms.fields.ChoiceField",
{"widget": "django.forms.Select", "choices": ((None, "-----"), ("yes", "Yes"), ("no", "No"))},
2016-09-14 17:21:16 +00:00
],
# note this intentionally uses a tuple so that we can test immutable
2025-10-07 09:25:07 +00:00
"email": ("django.forms.fields.EmailField",),
"array": ["django.forms.fields.CharField", {"widget": "django.forms.Textarea"}],
"json": ["django.forms.fields.CharField", {"widget": "django.forms.Textarea"}],
}
2015-06-14 15:25:56 +00:00
USE_TZ = True
2010-08-25 13:08:07 +00:00
CONSTANCE_CONFIG = {
2025-10-07 09:25:07 +00:00
"INT_VALUE": (1, "some int"),
"BOOL_VALUE": (True, "true or false"),
"STRING_VALUE": ("Hello world", "greetings"),
"DECIMAL_VALUE": (Decimal("0.1"), "the first release version"),
"DATETIME_VALUE": (datetime(2010, 8, 23, 11, 29, 24), "time of the first commit"),
"FLOAT_VALUE": (3.1415926536, "PI"),
"DATE_VALUE": (date(2010, 12, 24), "Merry Chrismas"),
"TIME_VALUE": (time(23, 59, 59), "And happy New Year"),
"TIMEDELTA_VALUE": (timedelta(days=1, hours=2, minutes=3), "Interval"),
"CHOICE_VALUE": ("yes", "select yes or no", "yes_no_null_select"),
"LINEBREAK_VALUE": ("Spam spam", "eggs\neggs"),
"EMAIL_VALUE": ("test@example.com", "An email", "email"),
"LIST_VALUE": ([1, "1", date(2019, 1, 1)], "A list", "array"),
"JSON_VALUE": (
{
2025-10-07 09:25:07 +00:00
"key": "value",
"key2": 2,
"key3": [1, 2, 3],
"key4": {"key": "value"},
"key5": date(2019, 1, 1),
"key6": None,
},
2025-10-07 09:25:07 +00:00
"A JSON object",
"json",
),
2010-08-25 13:08:07 +00:00
}
DEBUG = True
2013-04-12 16:17:42 +00:00
2025-10-07 09:25:07 +00:00
STATIC_ROOT = "./static/"
2013-04-12 16:17:42 +00:00
2025-10-07 09:25:07 +00:00
STATIC_URL = "/static/"
TEMPLATES = [
{
2025-10-07 09:25:07 +00:00
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.request",
"django.template.context_processors.static",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"constance.context_processors.config",
],
},
},
]