|
| 1 | +""" |
| 2 | +Settings configuration for the Django web framework. Update this |
| 3 | +configuration if you need to change the default behavior of |
| 4 | +Django during tests |
| 5 | +""" |
| 6 | +import os |
| 7 | +import django |
| 8 | + |
| 9 | + |
| 10 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 11 | + |
| 12 | +DATABASES = { |
| 13 | + 'default': { |
| 14 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 15 | + 'NAME': ':memory:' |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +SITE_ID = 1 |
| 20 | +SECRET_KEY = 'not_very_secret_in_tests' |
| 21 | +USE_I18N = True |
| 22 | +USE_L10N = True |
| 23 | +STATIC_URL = '/static/' |
| 24 | +ROOT_URLCONF = 'app.views' |
| 25 | + |
| 26 | +TEMPLATES = [ |
| 27 | + { |
| 28 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 29 | + 'DIRS': [ |
| 30 | + os.path.join(BASE_DIR, 'app', 'templates'), |
| 31 | + ], |
| 32 | + 'APP_DIRS': True, |
| 33 | + 'OPTIONS': { |
| 34 | + 'context_processors': [ |
| 35 | + 'django.template.context_processors.debug', |
| 36 | + 'django.template.context_processors.request', |
| 37 | + 'django.contrib.auth.context_processors.auth', |
| 38 | + 'django.contrib.messages.context_processors.messages', |
| 39 | + ], |
| 40 | + }, |
| 41 | + }, |
| 42 | +] |
| 43 | + |
| 44 | +if django.VERSION >= (1, 10): |
| 45 | + MIDDLEWARE = [ |
| 46 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 47 | + 'django.middleware.common.CommonMiddleware', |
| 48 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 49 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 50 | + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
| 51 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 52 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 53 | + 'django.middleware.security.SecurityMiddleware', |
| 54 | + |
| 55 | + 'tests.contrib.django.app.middlewares.CatchExceptionMiddleware', |
| 56 | + ] |
| 57 | + |
| 58 | +# Always add the legacy conf to make sure we handle it properly |
| 59 | +# Pre 1.10 style |
| 60 | +MIDDLEWARE_CLASSES = [ |
| 61 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 62 | + 'django.middleware.common.CommonMiddleware', |
| 63 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 64 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 65 | + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
| 66 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 67 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 68 | + 'django.middleware.security.SecurityMiddleware', |
| 69 | + |
| 70 | + 'tests.contrib.django.app.middlewares.CatchExceptionMiddleware', |
| 71 | +] |
| 72 | + |
| 73 | +INSTALLED_APPS = [ |
| 74 | + 'django.contrib.admin', |
| 75 | + 'django.contrib.auth', |
| 76 | + 'django.contrib.contenttypes', |
| 77 | + 'django.contrib.sessions', |
| 78 | + |
| 79 | + # tracer app |
| 80 | + 'ddtrace.contrib.django', |
| 81 | + |
| 82 | + # djangorestframework |
| 83 | + 'rest_framework' |
| 84 | +] |
| 85 | + |
| 86 | +DATADOG_TRACE = { |
| 87 | + # tracer with a DummyWriter |
| 88 | + 'TRACER': 'tests.contrib.django.utils.tracer', |
| 89 | + 'ENABLED': True, |
| 90 | + 'TAGS': { |
| 91 | + 'env': 'test', |
| 92 | + }, |
| 93 | +} |
| 94 | + |
| 95 | +REST_FRAMEWORK = { |
| 96 | + 'DEFAULT_PERMISSION_CLASSES': [ |
| 97 | + 'rest_framework.permissions.IsAdminUser', |
| 98 | + ], |
| 99 | + |
| 100 | + 'EXCEPTION_HANDLER': 'app.exceptions.custom_exception_handler' |
| 101 | +} |
0 commit comments