from pathlib import Path
from tempfile import gettempdir

BASE_DIR = Path(gettempdir()) / "ocyan-main-tests"
TEST_STATIC_SOURCE = BASE_DIR / "static-source"
for directory in (BASE_DIR / "static", TEST_STATIC_SOURCE, BASE_DIR / "media"):
    directory.mkdir(parents=True, exist_ok=True)

SECRET_KEY = "ocyan-main-test-key"
DEBUG = True
ALLOWED_HOSTS = ["testserver", "localhost"]

INSTALLED_APPS = [
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.staticfiles",
    "compressor",
    "ocyan.main",
    "sorl.thumbnail",
]

DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
SITE_ID = 1

ROOT_URLCONF = "ocyan.main.test_urls"
STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = [TEST_STATIC_SOURCE]
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"

TEMPLATES = [
    {
        "BACKEND": "ocyan.main.template.OcyanDjangoTemplates",
        "DIRS": [],
        "APP_DIRS": False,
        "OPTIONS": {
            "context_processors": ["django.template.context_processors.request"],
            "loaders": ["django.template.loaders.app_directories.Loader"],
        },
    }
]

FORM_RENDERER = "ocyan.main.renderers.OcyanFormRenderer"
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
USE_TZ = True
