forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_test.py
166 lines (122 loc) · 4.62 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from settings import * # noqa
import atexit
import tempfile
from django.utils.functional import lazy
_tmpdirs = set()
def _cleanup():
try:
import sys
import shutil
except ImportError:
return
tmp = None
try:
for tmp in _tmpdirs:
shutil.rmtree(tmp)
except Exception, exc:
sys.stderr.write("\n** shutil.rmtree(%r): %s\n" % (tmp, exc))
atexit.register(_cleanup)
def _polite_tmpdir():
tmp = tempfile.mkdtemp()
_tmpdirs.add(tmp)
return tmp
# Make sure the app needed to test translations is present.
INSTALLED_APPS += TEST_INSTALLED_APPS
# See settings.py for documentation:
IN_TEST_SUITE = True
MEDIA_ROOT = _polite_tmpdir()
TMP_PATH = _polite_tmpdir()
# Don't call out to persona in tests.
AUTHENTICATION_BACKENDS = (
'users.backends.AmoUserBackend',
)
CELERY_ALWAYS_EAGER = True
DEBUG = False
TEMPLATE_DEBUG = False
# We won't actually send an email.
SEND_REAL_EMAIL = True
# Turn off search engine indexing.
USE_ELASTIC = False
# Ensure all validation code runs in tests:
VALIDATE_ADDONS = True
PAYPAL_PERMISSIONS_URL = ''
ENABLE_API_ERROR_SERVICE = False
SITE_URL = 'http://testserver'
MOBILE_SITE_URL = ''
# COUNT() caching can't be invalidated, it just expires after x seconds. This
# is just too annoying for tests, so disable it.
CACHE_COUNT_TIMEOUT = -1
# Overrides whatever storage you might have put in local settings.
DEFAULT_FILE_STORAGE = 'amo.utils.LocalFileStorage'
VIDEO_LIBRARIES = ['lib.video.dummy']
ALLOW_SELF_REVIEWS = True
# Make sure the debug toolbar isn't used during the tests.
INSTALLED_APPS = [app for app in INSTALLED_APPS if app != 'debug_toolbar']
MOZMARKET_VENDOR_EXCLUDE = []
# These are the default languages. If you want a constrainted set for your
# tests, you should add those in the tests.
AMO_LANGUAGES = (
'af', 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en-US', 'es', 'eu', 'fa',
'fi', 'fr', 'ga-IE', 'he', 'hu', 'id', 'it', 'ja', 'ko', 'mn', 'nl', 'pl',
'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl', 'sq', 'sv-SE', 'uk', 'vi',
'zh-CN', 'zh-TW',
)
LANGUAGES = lazy(lazy_langs, dict)(AMO_LANGUAGES)
LANGUAGE_URL_MAP = dict([(i.lower(), i) for i in AMO_LANGUAGES])
TASK_USER_ID = '4043307'
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
'users.models.SHA512PasswordHasher',
)
SQL_RESET_SEQUENCES = False
ES_DEFAULT_NUM_REPLICAS = 0
ES_DEFAULT_NUM_SHARDS = 3
# Ensure that exceptions aren't re-raised.
DEBUG_PROPAGATE_EXCEPTIONS = False
###############################################################################
# Only if running on a CI server.
###############################################################################
if os.environ.get('RUNNING_IN_CI'):
import product_details
LOG_LEVEL = logging.ERROR
class MockProductDetails:
"""Main information we need in tests.
We don't want to rely on the product_details that are automatically
downloaded in manage.py for the tests. Also, downloading all the
information is very long, and we don't want that for each test build on
travis for example.
So here's a Mock that can be used instead of the real product_details.
"""
last_update = False
languages = dict((lang, {'native': lang}) for lang in AMO_LANGUAGES)
firefox_versions = {"LATEST_FIREFOX_VERSION": "33.1.1"}
thunderbird_versions = {"LATEST_THUNDERBIRD_VERSION": "31.2.0"}
firefox_history_major_releases = {'1.0': '2004-11-09'}
def __init__(self):
"""Some tests need specifics languages.
This is an excerpt of lib/product_json/languages.json.
"""
self.languages.update({
u'el': {
u'native':
u'\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac',
u'English': u'Greek'},
u'hr': {
u'native': u'Hrvatski',
u'English': u'Croatian'},
u'sr': {
u'native': u'\u0421\u0440\u043f\u0441\u043a\u0438',
u'English': u'Serbian'},
u'en-US': {
u'native': u'English (US)',
u'English': u'English (US)'},
u'tr': {
u'native': u'T\xfcrk\xe7e',
u'English': u'Turkish'},
u'cy': {
u'native': u'Cymraeg',
u'English': u'Welsh'},
u'sr-Latn': {
u'native': u'Srpski',
u'English': u'Serbian'}})
product_details.product_details = MockProductDetails()