bottleneckcrm/backend/crm/test_settings.py

46 lines
2 KiB
Python

"""
Test settings for Django CRM backend.
Strictly PostgreSQL only.
"""
from crm.settings import * # noqa: F401, F403
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("DB_NAME", os.environ.get("DBNAME", "tradhoxcrm")),
"USER": os.environ.get("DB_USER", os.environ.get("DBUSER", "vignesh")),
"PASSWORD": os.environ.get("DB_PASSWORD", os.environ.get("DBPASSWORD", "vignesh_secret_pass_2026")),
"HOST": os.environ.get("DB_HOST", os.environ.get("DBHOST", "16.113.106.152")),
"PORT": int(os.environ.get("DB_PORT", os.environ.get("DBPORT", "5432"))),
"CONN_MAX_AGE": 0,
}
}
# Disable Celery broker/result backend in tests (no Redis needed)
CELERY_BROKER_URL = "memory://"
CELERY_RESULT_BACKEND = "cache+memory://"
# The default PBKDF2 hasher costs ~190ms per hash. Fixtures create users on
# nearly every test, so that dominates the run. MD5 is fine here: it is never
# used outside crm.test_settings, and no test asserts on the hash algorithm.
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
# Uploads land in a throwaway directory rather than in `backend/media/`.
# Without this every attachment test leaves its file behind: the tree had grown
# to 51 MB of `update_YXw1f7b.txt` and friends by the time anyone looked, and
# the size-limit test below writes a 25 MB file on every run.
#
# `mkdtemp` rather than `TemporaryDirectory` because nothing here would call
# `cleanup()`; the OS reclaims it, and a test that needs to read back a file it
# just wrote still can.
import tempfile # noqa: E402
MEDIA_ROOT = tempfile.mkdtemp(prefix="bottlecrm-test-media-")
# This API's public origin (`common.links.api_url`), pinned so the calendar feed
# URL and web form embed snippets do not depend on the developer's own `.env`.
# Deliberately not `testserver`: a test that sees this host knows the URL came
# from the setting and not from the incoming request.
DOMAIN_NAME = "https://api.example.com"