Files
thrillwiki_django_no_react/backend/config/django/test.py
pacnpal edcd8f2076 Add secret management guide, client-side performance monitoring, and search accessibility enhancements
- Introduced a comprehensive Secret Management Guide detailing best practices, secret classification, development setup, production management, rotation procedures, and emergency protocols.
- Implemented a client-side performance monitoring script to track various metrics including page load performance, paint metrics, layout shifts, and memory usage.
- Enhanced search accessibility with keyboard navigation support for search results, ensuring compliance with WCAG standards and improving user experience.
2025-12-23 16:41:42 -05:00

114 lines
4.0 KiB
Python

"""
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