forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings_test.py
104 lines (83 loc) · 3.35 KB
/
settings_test.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
# -*- coding: utf-8 -*-
from settings import * # noqa
# Make sure the apps needed to test translations and core are present.
INSTALLED_APPS += (
'olympia.translations.tests.testapp',
'olympia.core.tests.db_tests_testapp',
'olympia.core.tests.m2m_testapp',
)
# Make sure the debug toolbar isn't used during the tests.
INSTALLED_APPS = [app for app in INSTALLED_APPS if app != 'debug_toolbar']
MIDDLEWARE = tuple(
middleware for middleware in MIDDLEWARE
if middleware != 'debug_toolbar.middleware.DebugToolbarMiddleware'
)
INTERNAL_ROUTES_ALLOWED = env('INTERNAL_ROUTES_ALLOWED', default=False)
# See settings.py for documentation:
IN_TEST_SUITE = True
# Don't call out to persona in tests.
AUTHENTICATION_BACKENDS = (
'olympia.users.backends.TestUserBackend',
)
DEBUG = False
# We won't actually send an email.
SEND_REAL_EMAIL = True
SITE_URL = CDN_HOST = EXTERNAL_SITE_URL = 'http://testserver'
INTERNAL_SITE_URL = 'http://testserver'
STATIC_URL = '%s/static/' % CDN_HOST
MEDIA_URL = '%s/user-media/' % CDN_HOST
# We are setting memcached here to make sure our test setup is as close
# to our production system as possible.
CACHES = {
'default': {
# `CacheStatTracker` is required for `assert_cache_requests` to work
# properly
'BACKEND': 'olympia.lib.cache.CacheStatTracker',
'LOCATION': os.environ.get('MEMCACHE_LOCATION', 'localhost:11211'),
'OPTIONS': {
'ACTUAL_BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', # noqa
}
},
}
# Overrides whatever storage you might have put in local settings.
DEFAULT_FILE_STORAGE = 'olympia.amo.utils.LocalFileStorage'
TASK_USER_ID = 1337
# Make sure we have no replicas and only one shard to allow for impedent
# search scoring
ES_DEFAULT_NUM_REPLICAS = 0
ES_DEFAULT_NUM_SHARDS = 1
# Don't enable the signing by default in tests, many would fail trying to sign
# empty or bad zip files, or try posting to the endpoints. We don't want that.
SIGNING_SERVER = ''
# Disable addon signing for unittests, too many would fail trying to sign
# corrupt/bad zip files. These will be enabled explicitly for unittests.
ENABLE_ADDON_SIGNING = False
# Limit logging in tests.
LOGGING['root']['handlers'] = ['null']
for logger in list(LOGGING['loggers'].keys()):
LOGGING['loggers'][logger]['handlers'] = ['null']
# Need to disable celery logging explicitly. Celery configures its logging
# manually and we don't catch their logger in our default config.
LOGGING['loggers']['celery'] = {
'handlers': ['null'],
'level': logging.DEBUG,
'propagate': False
}
# To speed tests up, crushing uploaded images is disabled in tests except
# where we explicitly want to test pngcrush.
PNGCRUSH_BIN = '/bin/true'
BASKET_API_KEY = 'testkey'
# By default all tests are run in always-eager mode. Use `CeleryWorkerTestCase`
# to start an actual celery worker instead.
CELERY_TASK_ALWAYS_EAGER = True
CELERY_IMPORTS += (
'olympia.amo.tests.test_celery',
'olympia.lib.es.tests.test_commands',
)
CELERY_TASK_ROUTES.update({
# Test tasks that will never really be triggered in prod.
'olympia.amo.tests.test_celery.fake_task': {'queue': 'amo'},
'olympia.amo.tests.test_celery.fake_task_with_result': {'queue': 'amo'},
'olympia.amo.tests.test_celery.sleeping_task': {'queue': 'amo'},
'olympia.lib.es.tests.test_commands.dummy_task': {'queue': 'amo'},
})