forked from dimagi/commcare-hq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testsettings.py
124 lines (101 loc) · 3.89 KB
/
testsettings.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
import os
import settingshelper as helper
from settings import * # noqa: F403
if os.environ.get('ELASTICSEARCH_MAJOR_VERSION'):
ELASTICSEARCH_MAJOR_VERSION = int(os.environ.get('ELASTICSEARCH_MAJOR_VERSION'))
# note: the only reason these are prepended to INSTALLED_APPS is because of
# a weird travis issue with kafka. if for any reason this order causes problems
# it can be reverted whenever that's figured out.
# https://github.com/dimagi/commcare-hq/pull/10034#issuecomment-174868270
INSTALLED_APPS = (
'django_nose',
'testapps.test_elasticsearch',
'testapps.test_pillowtop',
) + tuple(INSTALLED_APPS) # noqa: F405
TEST_RUNNER = 'django_nose.BasicNoseRunner'
NOSE_ARGS = [
#'--no-migrations' # trim ~120s from test run with db tests
#'--with-fixture-bundling',
]
NOSE_PLUGINS = [
'corehq.tests.nose.HqTestFinderPlugin',
'corehq.tests.noseplugins.classcleanup.ClassCleanupPlugin',
'corehq.tests.noseplugins.dividedwerun.DividedWeRunPlugin',
'corehq.tests.noseplugins.djangomigrations.DjangoMigrationsPlugin',
'corehq.tests.noseplugins.cmdline_params.CmdLineParametersPlugin',
'corehq.tests.noseplugins.patches.PatchesPlugin',
'corehq.tests.noseplugins.redislocks.RedisLockTimeoutPlugin',
'corehq.tests.noseplugins.uniformresult.UniformTestResultPlugin',
# The following are not enabled by default
'corehq.tests.noseplugins.logfile.LogFilePlugin',
'corehq.tests.noseplugins.timing.TimingPlugin',
'corehq.tests.noseplugins.output.OutputPlugin',
# Uncomment to debug tests. Plugins have nice hooks for inspecting state
# before/after each test or context setup/teardown, etc.
#'corehq.tests.noseplugins.debug.DebugPlugin',
]
# these settings can be overridden with environment variables
for key, value in {
'NOSE_DB_TEST_CONTEXT': 'corehq.tests.nose.HqdbContext',
'NOSE_NON_DB_TEST_CONTEXT': 'corehq.tests.nose.ErrorOnDbAccessContext',
'NOSE_IGNORE_FILES': '^localsettings',
'NOSE_EXCLUDE_DIRS': 'scripts',
'DD_DOGSTATSD_DISABLE': 'true',
'DD_TRACE_ENABLED': 'false',
}.items():
os.environ.setdefault(key, value)
del key, value
if "SKIP_TESTS_REQUIRING_EXTRA_SETUP" not in globals():
SKIP_TESTS_REQUIRING_EXTRA_SETUP = False
CELERY_TASK_ALWAYS_EAGER = True
# keep a copy of the original PILLOWTOPS setting around in case other tests want it.
_PILLOWTOPS = PILLOWTOPS
PILLOWTOPS = {}
PHONE_TIMEZONES_HAVE_BEEN_PROCESSED = True
PHONE_TIMEZONES_SHOULD_BE_PROCESSED = True
ENABLE_PRELOGIN_SITE = True
# override dev_settings
CACHE_REPORTS = True
def _set_logging_levels(levels):
import logging
for path, level in levels.items():
logging.getLogger(path).setLevel(level)
_set_logging_levels({
# Quiet down noisy loggers. Selective removal can be handy for debugging.
'alembic': 'WARNING',
'corehq.apps.auditcare': 'INFO',
'boto3': 'WARNING',
'botocore': 'INFO',
'couchdbkit.request': 'INFO',
'couchdbkit.designer': 'WARNING',
'datadog': 'WARNING',
'elasticsearch': 'ERROR',
'kafka.conn': 'WARNING',
'kafka.client': 'WARNING',
'kafka.consumer.kafka': 'WARNING',
'kafka.metrics': 'WARNING',
'kafka.protocol.parser': 'WARNING',
'kafka.producer': 'WARNING',
'quickcache': 'INFO',
'requests.packages.urllib3': 'WARNING',
's3transfer': 'INFO',
'urllib3': 'WARNING',
})
# use empty LOGGING dict with --debug=nose,nose.plugins to debug test discovery
# TODO empty logging config (and fix revealed deprecation warnings)
LOGGING = {
'disable_existing_loggers': False,
'version': 1,
'loggers': {},
}
helper.assign_test_db_names(DATABASES)
# See comment under settings.SMS_QUEUE_ENABLED
SMS_QUEUE_ENABLED = False
# use all providers in tests
METRICS_PROVIDERS = [
'corehq.util.metrics.datadog.DatadogMetrics',
'corehq.util.metrics.prometheus.PrometheusMetrics',
]
# timeout faster in tests
ES_SEARCH_TIMEOUT = 5
FORMPLAYER_INTERNAL_AUTH_KEY = "abc123"