-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_settings.py
More file actions
123 lines (106 loc) · 3.49 KB
/
test_settings.py
File metadata and controls
123 lines (106 loc) · 3.49 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
"""
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 edx_django_utils.plugins.plugin_apps import get_plugin_apps
from edx_django_utils.plugins.plugin_settings import add_plugins
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": "default.db",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
}
}
# Plugin Settings
ENABLE_PLUGINS = True
# Define both contexts for reference, but we'll only use one for testing
PLUGIN_CONTEXTS = ["lms.djangoapp", "cms.djangoapp"]
# We only use the LMS context for testing as the plugin is configured similarly for both
# Could use CMS context instead by changing the index to 1
# Base INSTALLED_APPS before plugin discovery
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"rest_framework",
"django_filters",
"edx_django_utils.plugins",
"django_extensions",
"organizations",
"openedx_catalog",
]
# Dynamically add plugin apps - only using the LMS context for simplicity
plugin_apps = get_plugin_apps(PLUGIN_CONTEXTS[0])
INSTALLED_APPS.extend(plugin_apps)
LOCALE_PATHS = [
root("openedx_plugin_sample", "conf", "locale"),
]
ROOT_URLCONF = "tests.urls"
SECRET_KEY = "insecure-secret-key"
MIDDLEWARE = (
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
)
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": False,
"OPTIONS": {
"context_processors": [
"django.contrib.auth.context_processors.auth", # this is required for admin
"django.template.context_processors.request", # this is also required for admin navigation sidebar
"django.contrib.messages.context_processors.messages", # this is required for admin
],
},
}
]
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.SessionAuthentication",
],
"DEFAULT_FILTER_BACKENDS": [
"django_filters.rest_framework.DjangoFilterBackend",
"rest_framework.filters.OrderingFilter",
],
"DEFAULT_THROTTLE_CLASSES": [
"rest_framework.throttling.AnonRateThrottle",
"rest_framework.throttling.UserRateThrottle",
],
"DEFAULT_THROTTLE_RATES": {
"anon": "20/hour",
"user": "100/hour",
},
}
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"root": {
"handlers": ["console"],
"level": "DEBUG",
},
}
# Apply plugin settings - must be done after base settings are defined
# Only using the LMS context for simplicity
# Third parameter is the settings_type which should match the keys in settings_config
add_plugins(__name__, PLUGIN_CONTEXTS[0], "test")