Files
guilan-ace-backend/config/settings/test.py
Amirhossein Khalili ff99130938 test: migrate backend suites to pytest with module coverage gate
Split backend tests into unit and integration suites, add isolated fixtures and coverage enforcement, and update CI and test documentation. Cover current authentication, content, notification, payment, media, and admin flows; fix behaviors revealed by the new tests. Validate both suites and the per-module gate against local PostgreSQL.
2026-09-26 16:50:29 +03:30

50 lines
1.6 KiB
Python

from tempfile import TemporaryDirectory
from .base import *
# Lightweight defaults keep local/CI test runs isolated from production infra.
TEST_DB_ENGINE = config("TEST_DB_ENGINE", default="django.db.backends.sqlite3")
TEST_DB_NAME = config("TEST_DB_NAME", default=str(BASE_DIR / "db.test.sqlite3"))
TEST_DB_USER = config("TEST_DB_USER", default="")
TEST_DB_PASSWORD = config("TEST_DB_PASSWORD", default="")
TEST_DB_HOST = config("TEST_DB_HOST", default="")
TEST_DB_PORT = config("TEST_DB_PORT", default="")
DATABASES["default"] = {
"ENGINE": TEST_DB_ENGINE,
"NAME": TEST_DB_NAME,
"USER": TEST_DB_USER,
"PASSWORD": TEST_DB_PASSWORD,
"HOST": TEST_DB_HOST,
"PORT": TEST_DB_PORT,
}
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
}
CELERY_TASK_ALWAYS_EAGER = True
CELERY_TASK_EAGER_PROPAGATES = True
_test_static_root = TemporaryDirectory(prefix="backend-test-static-")
STATIC_ROOT = _test_static_root.name
# Tests should not enforce HTTPS-only cookies to simplify client simulations.
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
# Silence verbose INFO logs (e.g., Celery task output) during tests.
LOGGING["handlers"]["console"]["level"] = "ERROR" # type: ignore[index]
LOGGING["root"]["level"] = "ERROR" # type: ignore[index]
if "django" in LOGGING["loggers"]:
LOGGING["loggers"]["django"]["level"] = "ERROR" # type: ignore[index]
if "apps" in LOGGING["loggers"]:
LOGGING["loggers"]["apps"]["level"] = "ERROR" # type: ignore[index]