""" Test settings for thrillwiki project. This module extends base.py with test-specific configurations: - Debug disabled for realistic testing - PostGIS database for GeoDjango support - In-memory cache for isolation - Simplified password hashing for speed - Disabled logging to reduce noise """ import os from .base import * # noqa: F401,F403 # ============================================================================= # Test Core Settings # ============================================================================= DEBUG = False # ============================================================================= # Test Database Configuration # ============================================================================= # Use PostGIS for GeoDjango support - required for spatial queries in tests DATABASES = { "default": { "ENGINE": "django.contrib.gis.db.backends.postgis", "NAME": os.environ.get("TEST_DB_NAME", "test_thrillwiki"), "USER": os.environ.get("TEST_DB_USER", "postgres"), "PASSWORD": os.environ.get("TEST_DB_PASSWORD", "postgres"), "HOST": os.environ.get("TEST_DB_HOST", "localhost"), "PORT": os.environ.get("TEST_DB_PORT", "5432"), "TEST": { "NAME": os.environ.get("TEST_DB_NAME", "test_thrillwiki"), }, } } # ============================================================================= # Test Cache Configuration # ============================================================================= # Use in-memory cache for test isolation CACHES = { "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "test-cache", }, "sessions": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "test-sessions", }, "api": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "test-api", }, } # ============================================================================= # Email Configuration # ============================================================================= # Use in-memory email backend for test assertions EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" # ============================================================================= # Password Hashing # ============================================================================= # Use fast MD5 hashing for tests (never use in production!) PASSWORD_HASHERS = [ "django.contrib.auth.hashers.MD5PasswordHasher", ] # ============================================================================= # Logging Configuration # ============================================================================= # Disable logging during tests to reduce noise LOGGING_CONFIG = None # ============================================================================= # Static and Media Files # ============================================================================= # Use test-specific directories MEDIA_ROOT = BASE_DIR / "test_media" # noqa: F405 STATIC_ROOT = BASE_DIR / "test_static" # noqa: F405 # ============================================================================= # Security Settings # ============================================================================= # Disable security features that interfere with testing TURNSTILE_SITE_KEY = "test-key" TURNSTILE_SECRET_KEY = "test-secret" # ============================================================================= # Middleware Configuration # ============================================================================= # Remove caching middleware for test isolation MIDDLEWARE = [m for m in MIDDLEWARE if "cache" not in m.lower()] # noqa: F405 # ============================================================================= # Celery Configuration # ============================================================================= # Run tasks synchronously during tests CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_EAGER_PROPAGATES = True