-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_settings.py
126 lines (106 loc) · 2.96 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
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
"""
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.
"""
import logging
import os
import subprocess
import sys
from logging import config as logging_config
import django
from os.path import abspath, dirname, join
DEBUG = True
def root(*args):
"""
Get the absolute path of the given path relative to the project root.
"""
return join(abspath(dirname(__file__)), *args)
if DEBUG:
ALLOWED_HOSTS = ['*']
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'pgdb',
# 'USER': 'pguser',
# 'PASSWORD': 'pgpass',
# 'HOST': 'localhost',
# 'PORT': 5432
# },
# }
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "memory"
}
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django_elastic_migrations',
'tests'
)
ROOT_URLCONF = 'django_elastic_migrations.urls'
SECRET_KEY = 'insecure-secret-key'
# parameters to pass to base Elasticsearch() instance
# https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch
ELASTICSEARCH_PARAMS = {
'hosts': [
'localhost:9200'
],
}
ELASTICSEARCH_INDEX_SETTINGS = {
"number_of_shards": 1,
"number_of_replicas": 0
}
LOGGING = {
"version": 1,
"formatters": {
"message": {
"format": "%(levelname)s %(asctime)s %(module)s %(message)s"
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"": {
"handlers": [
"console"
],
"level": "INFO",
"propagate": True
},
"django_elastic_migrations": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False
},
"elasticsearch": {
"handlers": ["console"],
"level": "WARNING",
# locally when debugging tests, this may help:
# "level": "DEBUG",
"propagate": False
},
"elasticsearch_dsl": {
"handlers": ["console"],
"level": "WARNING",
"propagate": False
}
},
}
logging_config.dictConfig(LOGGING)
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# logger = logging.getLogger(__name__)
# logger.debug("using cwd {}".format(root()))
# logger.debug("using python path: {}".format(sys.path))
DJANGO_ELASTIC_MIGRATIONS_ES_CLIENT = "tests.es_config.ES_CLIENT"
DJANGO_ELASTIC_MIGRATIONS_RECREATE_CONNECTIONS = "tests.es_config.dem_recreate_service_connections"
DJANGO_ELASTIC_MIGRATIONS_CLOSE_CONNECTIONS = "tests.es_config.dem_close_service_connections"
DJANGO_ELASTIC_MIGRATIONS_INDEXES = [
"tests.search.MovieSearchIndex",
]
DJANGO_ELASTIC_MIGRATIONS_ENVIRONMENT_PREFIX = "test_"