From 9b2124867ab1b22498e5d3b943dd9afe8513a0de Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:32:03 -0400 Subject: [PATCH] Add PostgreSQL test settings for thrillwiki project --- config/django/test_postgres.py | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 config/django/test_postgres.py diff --git a/config/django/test_postgres.py b/config/django/test_postgres.py new file mode 100644 index 00000000..4ac94ebd --- /dev/null +++ b/config/django/test_postgres.py @@ -0,0 +1,60 @@ +""" +PostgreSQL test settings for thrillwiki project. +""" + +from .base import * # noqa: F403,F405 +import os + +# Test-specific settings +DEBUG = False + +# Use PostgreSQL for tests to support ArrayField +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", ""), + "HOST": os.environ.get("TEST_DB_HOST", "localhost"), + "PORT": os.environ.get("TEST_DB_PORT", "5432"), + "TEST": { + "NAME": "test_thrillwiki_test", + }, + } +} + +# Use in-memory cache for tests +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "test-cache", + } +} + +# Email backend for tests +EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" + +# Password hashers for faster tests +PASSWORD_HASHERS = [ + "django.contrib.auth.hashers.MD5PasswordHasher", +] + +# Disable logging during tests +LOGGING_CONFIG = None + +# Media files for tests +MEDIA_ROOT = BASE_DIR / "test_media" + +# Static files for tests +STATIC_ROOT = BASE_DIR / "test_static" + +# Disable Turnstile for tests +TURNSTILE_SITE_KEY = "test-key" +TURNSTILE_SECRET_KEY = "test-secret" + +# Test-specific middleware (remove caching middleware) +MIDDLEWARE = [m for m in MIDDLEWARE if "cache" not in m.lower()] + +# Celery settings for tests (if Celery is used) +CELERY_TASK_ALWAYS_EAGER = True +CELERY_TASK_EAGER_PROPAGATES = True