174 lines
4.1 KiB
Python
174 lines
4.1 KiB
Python
"""
|
|
Standalone test settings for Django FBF tests.
|
|
This file provides all necessary Django settings without relying on environment variables.
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
# Add the app directory to Python path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'app'))
|
|
|
|
# Basic Django settings
|
|
DEBUG = False
|
|
TESTING = True
|
|
SECRET_KEY = 'test-secret-key-for-django-fbf-tests-only'
|
|
|
|
# Database settings for tests
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': ':memory:',
|
|
}
|
|
}
|
|
|
|
# Basic Django apps
|
|
DJANGO_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
]
|
|
|
|
# Third party apps
|
|
THIRD_PARTY_APPS = [
|
|
'crispy_forms',
|
|
'crispy_bootstrap5',
|
|
'allauth',
|
|
'allauth.account',
|
|
'bootstrap_datepicker_plus',
|
|
'bootstrap_modal_forms',
|
|
'django_ckeditor_5',
|
|
]
|
|
|
|
# Local apps
|
|
LOCAL_APPS = [
|
|
'bird',
|
|
'aviary',
|
|
'contact',
|
|
'costs',
|
|
'export',
|
|
'sendemail',
|
|
]
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
|
|
|
# Middleware
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
'allauth.account.middleware.AccountMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'core.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [os.path.join(os.path.dirname(__file__), '..', 'app', 'templates')],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'core.wsgi.application'
|
|
|
|
# Basic settings
|
|
ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'testserver']
|
|
USE_TZ = True
|
|
TIME_ZONE = 'Europe/Berlin'
|
|
LANGUAGE_CODE = 'de-de'
|
|
USE_I18N = True
|
|
|
|
# Disable migrations for faster tests
|
|
class DisableMigrations:
|
|
def __contains__(self, item):
|
|
return True
|
|
|
|
def __getitem__(self, item):
|
|
return None
|
|
|
|
MIGRATION_MODULES = DisableMigrations()
|
|
|
|
# Faster password hashing for tests
|
|
PASSWORD_HASHERS = [
|
|
'django.contrib.auth.hashers.MD5PasswordHasher',
|
|
]
|
|
|
|
# Disable logging during tests
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'handlers': {
|
|
'null': {
|
|
'class': 'logging.NullHandler',
|
|
},
|
|
},
|
|
'root': {
|
|
'handlers': ['null'],
|
|
},
|
|
}
|
|
|
|
# Email backend for tests
|
|
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
|
|
|
# Cache settings for tests
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
|
}
|
|
}
|
|
|
|
# Media files for tests
|
|
import tempfile
|
|
MEDIA_ROOT = tempfile.mkdtemp()
|
|
MEDIA_URL = '/media/'
|
|
|
|
# Static files for tests
|
|
STATIC_ROOT = tempfile.mkdtemp()
|
|
STATIC_URL = '/static/'
|
|
|
|
# Auth settings
|
|
LOGIN_URL = '/accounts/login/'
|
|
LOGIN_REDIRECT_URL = '/'
|
|
LOGOUT_REDIRECT_URL = '/'
|
|
|
|
# Crispy forms
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap5'
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap5'
|
|
|
|
# CKEditor 5 settings for tests
|
|
CKEDITOR_5_CONFIGS = {
|
|
'default': {
|
|
'toolbar': ['bold', 'italic', 'underline', '|', 'bulletedList', 'numberedList'],
|
|
},
|
|
}
|
|
|
|
# Celery settings for tests
|
|
CELERY_TASK_ALWAYS_EAGER = True
|
|
CELERY_TASK_EAGER_PROPAGATES = True
|
|
|
|
# Default primary key field type
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
# Security settings for tests
|
|
SECURE_SSL_REDIRECT = False
|
|
SECURE_HSTS_SECONDS = 0
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
|
|
SECURE_HSTS_PRELOAD = False
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
X_FRAME_OPTIONS = 'DENY'
|