-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_settings.py
65 lines (56 loc) · 2.04 KB
/
test_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
import os
import celery
# Django3では、標準のdjango.conf.global_settingsの定数をオーバーライドすると例外が発生する場合がある。
# https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188
# そのため、testではdjango.conf.global_settingsを直接利用せず、このtest用settings定数を使用する。
SECRET_KEY = "SECRET"
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'beproud.django.notify',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
BASE_PATH = os.path.dirname(__file__)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_PATH, 'beproud', 'django', 'notify', 'tests', 'templates')
],
},
]
USE_TZ = False # For Django 5.0+
BPNOTIFY_MEDIA = {
"news": {
"verbose_name": "News",
"default_types": ("new_user", "follow", "private_msg"),
"backends": (
"beproud.django.notify.backends.model.ModelBackend",
),
},
"private_messages": {
"verbose_name": "Private Message",
"default_types": ("private_msg", "notify_type_with_length_over_thirty"),
"backends": (
"beproud.django.notify.backends.model.ModelBackend",
"beproud.django.notify.backends.mail.EmailBackend",
),
},
}
BPNOTIFY_SETTINGS_STORAGE = 'beproud.django.notify.storage.db.DBStorage'
# For Celery Tests
app = celery.Celery()
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: INSTALLED_APPS)
BROKER_BACKEND = 'memory'
CELERY_TASK_ALWAYS_EAGER = True
# kombu.exceptions.EncodeError: Object of type User is not JSON serializable エラーを抑止する
# (参考)
# https://github.com/celery/celery/issues/5922
# https://stackoverflow.com/questions/49373825/kombu-exceptions-encodeerror-user-is-not-json-serializable
CELERY_TASK_SERIALIZER = "pickle"