|
| 1 | +"""Django settings for tests.""" |
| 2 | + |
| 3 | +import os |
| 4 | +from django_mongodb_cli.utils import get_databases |
| 5 | + |
| 6 | + |
| 7 | +DATABASES = get_databases("debug_toolbar") |
| 8 | + |
| 9 | +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
| 10 | + |
| 11 | + |
| 12 | +# Quick-start development settings - unsuitable for production |
| 13 | + |
| 14 | +SECRET_KEY = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" |
| 15 | + |
| 16 | +INTERNAL_IPS = ["127.0.0.1"] |
| 17 | + |
| 18 | +LOGGING = { # avoids spurious output in tests |
| 19 | + "version": 1, |
| 20 | + "disable_existing_loggers": True, |
| 21 | +} |
| 22 | + |
| 23 | + |
| 24 | +# Application definition |
| 25 | + |
| 26 | +INSTALLED_APPS = [ |
| 27 | + "debug_toolbar.mongo_apps.MongoAdminConfig", |
| 28 | + "debug_toolbar.mongo_apps.MongoAuthConfig", |
| 29 | + "debug_toolbar.mongo_apps.MongoContentTypesConfig", |
| 30 | + "django.contrib.sessions", |
| 31 | + "django.contrib.messages", |
| 32 | + "django.contrib.staticfiles", |
| 33 | + "debug_toolbar", |
| 34 | + "tests", |
| 35 | + "django_mongodb_extensions", |
| 36 | +] |
| 37 | + |
| 38 | + |
| 39 | +USE_GIS = os.getenv("DB_BACKEND") == "postgis" |
| 40 | + |
| 41 | +if USE_GIS: |
| 42 | + INSTALLED_APPS = ["django.contrib.gis"] + INSTALLED_APPS |
| 43 | + |
| 44 | +MEDIA_URL = "/media/" # Avoids https://code.djangoproject.com/ticket/21451 |
| 45 | + |
| 46 | +MIDDLEWARE = [ |
| 47 | + "tests.middleware.UseCacheAfterToolbar", |
| 48 | + "debug_toolbar.middleware.DebugToolbarMiddleware", |
| 49 | + "django.middleware.security.SecurityMiddleware", |
| 50 | + "django.contrib.sessions.middleware.SessionMiddleware", |
| 51 | + "django.middleware.common.CommonMiddleware", |
| 52 | + "django.middleware.csrf.CsrfViewMiddleware", |
| 53 | + "django.contrib.auth.middleware.AuthenticationMiddleware", |
| 54 | + "django.contrib.messages.middleware.MessageMiddleware", |
| 55 | + "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 56 | +] |
| 57 | + |
| 58 | +ROOT_URLCONF = "tests.urls" |
| 59 | + |
| 60 | +TEMPLATES = [ |
| 61 | + { |
| 62 | + "NAME": "jinja2", |
| 63 | + "BACKEND": "django.template.backends.jinja2.Jinja2", |
| 64 | + "APP_DIRS": True, |
| 65 | + "DIRS": [os.path.join(BASE_DIR, "tests", "templates", "jinja2")], |
| 66 | + }, |
| 67 | + { |
| 68 | + "BACKEND": "django.template.backends.django.DjangoTemplates", |
| 69 | + "APP_DIRS": True, |
| 70 | + "OPTIONS": { |
| 71 | + "context_processors": [ |
| 72 | + "django.template.context_processors.debug", |
| 73 | + "django.template.context_processors.request", |
| 74 | + "django.contrib.auth.context_processors.auth", |
| 75 | + "django.contrib.messages.context_processors.messages", |
| 76 | + ] |
| 77 | + }, |
| 78 | + }, |
| 79 | +] |
| 80 | + |
| 81 | +USE_TZ = True |
| 82 | + |
| 83 | +STATIC_ROOT = os.path.join(BASE_DIR, "tests", "static") |
| 84 | + |
| 85 | +STATIC_URL = "/static/" |
| 86 | + |
| 87 | +STATICFILES_DIRS = [ |
| 88 | + os.path.join(BASE_DIR, "tests", "additional_static"), |
| 89 | + ("prefix", os.path.join(BASE_DIR, "tests", "additional_static")), |
| 90 | +] |
| 91 | + |
| 92 | +# Cache and database |
| 93 | + |
| 94 | +CACHES = { |
| 95 | + "default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, |
| 96 | + "second": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}, |
| 97 | +} |
| 98 | + |
| 99 | +# Debug Toolbar configuration |
| 100 | + |
| 101 | +DEBUG_TOOLBAR_CONFIG = { |
| 102 | + # Django's test client sets wsgi.multiprocess to True inappropriately |
| 103 | + "RENDER_PANELS": False, |
| 104 | + # IS_RUNNING_TESTS must be False even though we're running tests because we're running the toolbar's own tests. |
| 105 | + "IS_RUNNING_TESTS": False, |
| 106 | +} |
| 107 | +DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" |
| 108 | +MIGRATION_MODULES = { |
| 109 | + "admin": None, |
| 110 | + "auth": None, |
| 111 | + "contenttypes": None, |
| 112 | +} |
| 113 | + |
| 114 | +DEBUG_TOOLBAR_PANELS = [ |
| 115 | + "django_mongodb_extensions.debug_toolbar.panels.mql.MQLPanel", |
| 116 | +] |
0 commit comments