2015-01-05 15:01:42 +01:00
|
|
|
"""
|
2016-09-08 11:13:21 +02:00
|
|
|
Settings file for OpenSlides' tests.
|
2015-01-05 15:01:42 +01:00
|
|
|
"""
|
2014-01-11 15:47:15 +01:00
|
|
|
import os
|
2015-06-16 10:37:23 +02:00
|
|
|
|
2013-09-25 10:01:01 +02:00
|
|
|
from openslides.global_settings import * # noqa
|
2013-03-14 22:18:56 +01:00
|
|
|
|
2018-07-09 23:22:26 +02:00
|
|
|
|
2014-01-11 15:47:15 +01:00
|
|
|
# Path to the directory for user specific data files
|
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
OPENSLIDES_USER_DATA_PATH = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
|
2013-03-14 22:18:56 +01:00
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
2014-01-11 15:47:15 +01:00
|
|
|
|
2015-01-22 18:29:12 +01:00
|
|
|
# OpenSlides plugins
|
2016-09-08 11:13:21 +02:00
|
|
|
|
2015-01-22 18:29:12 +01:00
|
|
|
# Add plugins to this list.
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
INSTALLED_PLUGINS += ("tests.integration.test_plugin",) # noqa
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2016-06-16 10:59:35 +02:00
|
|
|
INSTALLED_APPS += INSTALLED_PLUGINS # noqa
|
2013-03-18 21:50:50 +01:00
|
|
|
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
# Important settings for production use
|
|
|
|
# https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
SECRET_KEY = "secret"
|
2016-09-08 11:13:21 +02:00
|
|
|
|
|
|
|
DEBUG = False
|
|
|
|
|
2018-11-03 15:59:24 +01:00
|
|
|
# Uncomment to test with the redis cache
|
|
|
|
# REDIS_ADDRESS = "redis://127.0.0.1"
|
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
|
2015-01-05 15:01:42 +01:00
|
|
|
# Database
|
2016-09-08 11:13:21 +02:00
|
|
|
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
|
|
|
|
|
|
|
|
# Change this setting to use e. g. PostgreSQL or MySQL.
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2019-12-11 16:12:58 +01:00
|
|
|
DATABASES = {
|
|
|
|
"default": {
|
|
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
|
|
"TEST": {"NAME": os.path.join(OPENSLIDES_USER_DATA_PATH, "db.sqlite3.test")},
|
|
|
|
}
|
|
|
|
}
|
2018-09-23 22:02:09 +02:00
|
|
|
|
2018-07-09 23:22:26 +02:00
|
|
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
TIME_ZONE = "Europe/Berlin"
|
2014-01-11 15:47:15 +01:00
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
2013-09-08 14:44:41 +02:00
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
STATICFILES_DIRS.insert(0, os.path.join(OPENSLIDES_USER_DATA_PATH, "static")) # noqa
|
2015-01-05 15:01:42 +01:00
|
|
|
|
2016-09-08 11:13:21 +02:00
|
|
|
|
|
|
|
# Files
|
|
|
|
# https://docs.djangoproject.com/en/1.10/topics/files/
|
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
MEDIA_ROOT = os.path.join(OPENSLIDES_USER_DATA_PATH, "")
|
2016-09-08 11:13:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Special settings only for testing
|
|
|
|
|
2015-01-05 15:01:42 +01:00
|
|
|
# Use a faster password hasher.
|
2014-01-11 15:47:15 +01:00
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
2018-11-01 17:30:18 +01:00
|
|
|
|
|
|
|
# Deactivate restricted_data_cache
|
|
|
|
RESTRICTED_DATA_CACHE = False
|
2019-10-18 14:18:49 +02:00
|
|
|
|
|
|
|
REST_FRAMEWORK = {"TEST_REQUEST_DEFAULT_FORMAT": "json"}
|
2019-11-05 09:30:55 +01:00
|
|
|
|
|
|
|
ENABLE_ELECTRONIC_VOTING = True
|
2020-05-28 13:50:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
# https://stackoverflow.com/questions/24876343/django-traceback-on-queries
|
|
|
|
if os.environ.get("DEBUG_SQL_TRACEBACK"):
|
|
|
|
import traceback
|
2020-07-07 16:14:08 +02:00
|
|
|
|
|
|
|
from django.db.backends import utils as bakutils
|
2020-05-28 13:50:54 +02:00
|
|
|
|
|
|
|
cursor_debug_wrapper_orig = bakutils.CursorDebugWrapper
|
|
|
|
|
|
|
|
def print_stack_in_project(sql):
|
|
|
|
stack = traceback.extract_stack()
|
|
|
|
for path, lineno, func, line in stack:
|
|
|
|
if "lib/python" in path or "settings.py" in path:
|
|
|
|
continue
|
|
|
|
print(f'File "{path}", line {lineno}, in {func}')
|
|
|
|
print(f" {line}")
|
|
|
|
print(sql)
|
|
|
|
print("\n")
|
|
|
|
|
|
|
|
class CursorDebugWrapperLoud(cursor_debug_wrapper_orig): # type: ignore
|
|
|
|
def execute(self, sql, params=None):
|
|
|
|
try:
|
|
|
|
return super().execute(sql, params)
|
|
|
|
finally:
|
|
|
|
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
|
|
|
|
print_stack_in_project(sql)
|
|
|
|
|
|
|
|
def executemany(self, sql, param_list):
|
|
|
|
try:
|
|
|
|
return super().executemany(sql, param_list)
|
|
|
|
finally:
|
|
|
|
print_stack_in_project(sql)
|
|
|
|
|
|
|
|
bakutils.CursorDebugWrapper = CursorDebugWrapperLoud
|