-
Notifications
You must be signed in to change notification settings - Fork 7
/
settings.py
92 lines (84 loc) · 3.15 KB
/
settings.py
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
import os
import json
from django.conf import settings
def configure_settings():
"""
Configures settings for manage.py and for run_tests.py.
"""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
if not settings.configured:
# Determine the database settings depending on if a test_db var is set in CI mode or not
test_db = os.environ.get('DB', None)
if test_db is None:
db_config = {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'issue',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db'
}
elif test_db == 'postgres':
db_config = {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'issue',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db',
}
elif test_db == 'sqlite':
db_config = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'issue',
}
else:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))
# Check env for db override (used for github actions)
if os.environ.get('DB_SETTINGS'):
db_config = json.loads(os.environ.get('DB_SETTINGS'))
installed_apps = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'issue',
'issue.tests',
]
middleware = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
templates = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
settings.configure(
TEST_RUNNER='django_nose.NoseTestSuiteRunner',
NOSE_ARGS=['--nocapture', '--nologcapture', '--verbosity=1'],
DATABASES={
'default': db_config,
},
INSTALLED_APPS=installed_apps,
MIDDLEWARE=middleware,
TEMPLATES=templates,
ROOT_URLCONF='issue.urls',
DEBUG=False,
SECRET_KEY='*',
DEFAULT_AUTO_FIELD='django.db.models.AutoField',
)