File: settings.py

package info (click to toggle)
django-dbbackup 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 512 kB
  • sloc: python: 3,767; makefile: 7
file content (107 lines) | stat: -rw-r--r-- 2,875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
Configuration and launcher for dbbackup tests.
"""

import os
import sys
import tempfile

from dotenv import load_dotenv

test = len(sys.argv) <= 1 or sys.argv[1] == "test"
if not test:
    load_dotenv()

DEBUG = False

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
TESTAPP_DIR = os.path.join(BASE_DIR, "testapp/")
BLOB_DIR = os.path.join(TESTAPP_DIR, "blobs/")

ADMINS = (("ham", "foo@bar"),)
ALLOWED_HOSTS = ["*"]
MIDDLEWARE_CLASSES = ()
ROOT_URLCONF = "dbbackup.tests.testapp.urls"
SECRET_KEY = "it's a secret to everyone"
SITE_ID = 1
MEDIA_ROOT = os.environ.get("MEDIA_ROOT") or tempfile.mkdtemp()
INSTALLED_APPS = (
    "dbbackup",
    "dbbackup.tests.testapp",
)
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

DATABASES = {
    "default": {
        "ENGINE": os.environ.get("DB_ENGINE", "django.db.backends.sqlite3"),
        "NAME": os.environ.get("DB_NAME", ":memory:"),
        "USER": os.environ.get("DB_USER"),
        "PASSWORD": os.environ.get("DB_PASSWORD"),
        "HOST": os.environ.get("DB_HOST"),
    }
}
if os.environ.get("CONNECTOR"):
    CONNECTOR = {"CONNECTOR": os.environ["CONNECTOR"]}
    DBBACKUP_CONNECTORS = {"default": CONNECTOR}

CACHES = {
    "default": {
        "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
    }
}

SERVER_EMAIL = "dbbackup@test.org"

DBBACKUP_GPG_RECIPIENT = "test@test"
DBBACKUP_GPG_ALWAYS_TRUST = (True,)

DBBACKUP_STORAGE = os.environ.get("STORAGE", "dbbackup.tests.utils.FakeStorage")
DBBACKUP_STORAGE_OPTIONS = dict(
    [
        keyvalue.split("=")
        for keyvalue in os.environ.get("STORAGE_OPTIONS", "").split(",")
        if keyvalue
    ]
)

# For testing the new storages setting introduced in Django 4.2
STORAGES = {
    "default": {
        "BACKEND": "django.core.files.storage.FileSystemStorage",
        "OPTIONS": {},
    },
    "dbbackup": {
        "BACKEND": DBBACKUP_STORAGE,
        "OPTIONS": DBBACKUP_STORAGE_OPTIONS,
    },
}

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "root": {"handlers": ["console"], "level": "DEBUG"},
    "handlers": {
        "console": {
            "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
            "class": "logging.StreamHandler",
            "formatter": "simple",
        }
    },
    "formatters": {
        "verbose": {
            "format": "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            "datefmt": "%d/%b/%Y %H:%M:%S",
        },
        "simple": {"format": "%(levelname)s %(message)s"},
    },
    "loggers": {
        "django.db.backends": {
            # uncomment to see all queries
            # 'level': 'DEBUG',
            "handlers": ["console"],
        }
    },
}

# let there be silence
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"