Repository navigation
Expand file tree
/
Copy pathtest_settings.py
More file actions
137 lines (115 loc) · 4.06 KB
/
Copy pathtest_settings.py
File metadata and controls
137 lines (115 loc) · 4.06 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""
These settings are here to use during tests, because django requires them.
In a real-world use case, apps in this project are installed into other
Django applications, so these settings will not be used.
"""
from os.path import abspath, dirname, join
from openedx_content.settings_api import openedx_content_backcompat_apps_to_install
def root(*args):
"""
Get the absolute path of the given path relative to the project root.
"""
return join(abspath(dirname(__file__)), *args)
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
}
# If you provision the 'oel'@'%' with broad permissions on your MySQL instance,
# running the tests will auto-generate a database for running tests. This is
# slower than the default sqlite3 setup above, but it's sometimes helpful for
# finding things that only break in CI.
#
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.mysql",
# "USER": "oel",
# "PASSWORD": "oel-test-pass",
# "HOST": "mysql",
# "PORT": "3306",
# }
# }
INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.staticfiles",
# Admin
'django.contrib.admin',
'django.contrib.admindocs',
# Debugging
"debug_toolbar",
# Open edX Organizations (dependency for openedx_catalog)
"organizations",
# django-rules based authorization
'rules.apps.AutodiscoverRulesConfig',
# Required for django-simple-history's admin integration and management commands;
# HistoricalRecords() alone does not need it.
"simple_history",
# Our own apps
"openedx_tagging",
"openedx_content",
"openedx_catalog",
"openedx_learning",
*openedx_content_backcompat_apps_to_install(),
# Apps with models that are only used for testing
"tests.test_django_app",
]
AUTHENTICATION_BACKENDS = [
'rules.permissions.ObjectPermissionBackend',
]
LOCALE_PATHS = [
root("conf", "locale"),
]
ROOT_URLCONF = "projects.urls"
SECRET_KEY = "insecure-secret-key"
USE_TZ = True
MEDIA_ROOT = root("test_media")
# ========================= Django Rest Framework ========================
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'edx_rest_framework_extensions.paginators.DefaultPagination',
'PAGE_SIZE': 10,
}
# ========================= LEARNING CORE SETTINGS ========================
# TODO: Document & rename this setting (https://github.com/openedx/openedx-core/issues/481)
OPENEDX_LEARNING = {
'MEDIA': {
'BACKEND': 'django.core.files.storage.InMemoryStorage',
'OPTIONS': {
'location': MEDIA_ROOT + "_private"
}
}
}
STATIC_URL = 'static/'
# Required for Django admin which is required because it's referenced by projects.urls (ROOT_URLCONF)
TEMPLATES = [
{
'NAME': 'django',
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# Don't look for template source files inside installed applications.
# 'APP_DIRS': False,
# Instead, look for template source files in these dirs.
# 'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
'django.contrib.auth.context_processors.auth',
],
}
},
]
MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
]
# django-simple-history bakes this setting into the history_date field of every
# HistoricalRecords() model, and therefore into any migration we generate for one.
# openedx-platform has had this set to False since its 2023 django-simple-history
# upgrade (openedx/openedx-platform#32880), to avoid adding an index to every
# historical table in the platform at once. Our migrations run there, so this has
# to match.
SIMPLE_HISTORY_DATE_INDEX = False