2017-08-23 12:06:30 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-12-19 17:58:50 +03:00
|
|
|
from settings import * # noqa
|
|
|
|
|
2011-03-08 22:32:27 +03:00
|
|
|
import atexit
|
|
|
|
import tempfile
|
|
|
|
|
2012-09-06 02:25:36 +04:00
|
|
|
from django.utils.functional import lazy
|
2011-03-08 22:32:27 +03:00
|
|
|
|
2013-07-02 21:32:16 +04:00
|
|
|
|
2011-03-08 22:32:27 +03:00
|
|
|
_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
|
|
|
|
|
2014-12-19 17:58:50 +03:00
|
|
|
# Make sure the app needed to test translations is present.
|
|
|
|
INSTALLED_APPS += TEST_INSTALLED_APPS
|
|
|
|
|
2011-03-08 22:32:27 +03:00
|
|
|
# See settings.py for documentation:
|
2012-05-02 21:30:28 +04:00
|
|
|
IN_TEST_SUITE = True
|
2014-06-04 13:08:02 +04:00
|
|
|
MEDIA_ROOT = _polite_tmpdir()
|
2011-04-28 04:44:38 +04:00
|
|
|
TMP_PATH = _polite_tmpdir()
|
2011-06-28 21:37:12 +04:00
|
|
|
|
2014-04-02 19:28:50 +04:00
|
|
|
# Don't call out to persona in tests.
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
2016-10-12 18:52:00 +03:00
|
|
|
'olympia.users.backends.TestUserBackend',
|
2014-04-02 19:28:50 +04:00
|
|
|
)
|
|
|
|
|
2017-10-16 12:16:41 +03:00
|
|
|
CELERY_TASK_ALWAYS_EAGER = True
|
2014-11-17 18:55:02 +03:00
|
|
|
DEBUG = False
|
|
|
|
|
2011-08-23 01:24:19 +04:00
|
|
|
# We won't actually send an email.
|
|
|
|
SEND_REAL_EMAIL = True
|
|
|
|
|
2011-09-07 02:22:24 +04:00
|
|
|
PAYPAL_PERMISSIONS_URL = ''
|
2011-09-17 01:40:27 +04:00
|
|
|
|
2013-10-03 02:35:22 +04:00
|
|
|
SITE_URL = 'http://testserver'
|
2011-09-17 01:52:04 +04:00
|
|
|
|
2013-10-02 01:56:32 +04:00
|
|
|
# COUNT() caching can't be invalidated, it just expires after x seconds. This
|
|
|
|
# is just too annoying for tests, so disable it.
|
2014-03-26 23:57:38 +04:00
|
|
|
CACHE_COUNT_TIMEOUT = -1
|
2013-10-02 01:56:32 +04:00
|
|
|
|
2015-08-23 12:14:51 +03:00
|
|
|
# We don't want to share cache state between processes. Always use the local
|
|
|
|
# memcache backend for tests.
|
|
|
|
#
|
|
|
|
# Note: Per settings.py, this module can cause deadlocks when running as a web
|
|
|
|
# server. It's safe to use in tests, since we don't use threads, and there's
|
|
|
|
# no opportunity for contention, but it shouldn't be used in the base settings
|
|
|
|
# until we're sure the deadlock issues are fixed.
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'caching.backends.locmem.LocMemCache',
|
|
|
|
'LOCATION': 'olympia',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-01 21:16:38 +04:00
|
|
|
# Overrides whatever storage you might have put in local settings.
|
2015-12-17 09:59:16 +03:00
|
|
|
DEFAULT_FILE_STORAGE = 'olympia.amo.utils.LocalFileStorage'
|
2012-04-06 00:44:55 +04:00
|
|
|
|
2012-09-28 04:36:03 +04:00
|
|
|
ALLOW_SELF_REVIEWS = True
|
|
|
|
|
2014-12-19 17:58:50 +03:00
|
|
|
# Make sure the debug toolbar isn't used during the tests.
|
|
|
|
INSTALLED_APPS = [app for app in INSTALLED_APPS if app != 'debug_toolbar']
|
2012-06-23 02:57:43 +04:00
|
|
|
|
2017-01-23 16:12:00 +03:00
|
|
|
TASK_USER_ID = 1337
|
2012-11-01 19:32:08 +04:00
|
|
|
|
2013-09-07 09:03:53 +04:00
|
|
|
ES_DEFAULT_NUM_REPLICAS = 0
|
|
|
|
ES_DEFAULT_NUM_SHARDS = 3
|
2013-09-10 20:54:52 +04:00
|
|
|
|
2014-02-19 03:45:58 +04:00
|
|
|
# Ensure that exceptions aren't re-raised.
|
|
|
|
DEBUG_PROPAGATE_EXCEPTIONS = False
|
2014-12-19 17:58:50 +03:00
|
|
|
|
2015-03-07 21:48:55 +03:00
|
|
|
# Set to True if we're allowed to use X-SENDFILE.
|
|
|
|
XSENDFILE = True
|
|
|
|
|
2015-04-20 21:51:22 +03:00
|
|
|
# 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 = ''
|
2017-11-13 19:29:57 +03:00
|
|
|
|
|
|
|
# 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
|
2014-12-19 17:58:50 +03:00
|
|
|
|
2016-06-15 17:15:02 +03:00
|
|
|
# Limit logging in tests.
|
|
|
|
LOGGING = {
|
|
|
|
'loggers': {}
|
|
|
|
}
|
|
|
|
|
2014-12-19 17:58:50 +03:00
|
|
|
###############################################################################
|
|
|
|
# Only if running on a CI server.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
if os.environ.get('RUNNING_IN_CI'):
|
|
|
|
import product_details
|
2016-08-13 01:22:05 +03:00
|
|
|
from datetime import datetime
|
2014-12-19 17:58:50 +03:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
"""
|
2016-08-13 01:22:05 +03:00
|
|
|
last_update = datetime.now()
|
2014-12-19 17:58:50 +03:00
|
|
|
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': {
|
2017-08-23 12:06:30 +03:00
|
|
|
u'native': u'Ελληνικά',
|
2014-12-19 17:58:50 +03:00
|
|
|
u'English': u'Greek'},
|
|
|
|
u'hr': {
|
|
|
|
u'native': u'Hrvatski',
|
|
|
|
u'English': u'Croatian'},
|
|
|
|
u'sr': {
|
2017-08-23 12:06:30 +03:00
|
|
|
u'native': u'Dolnoserbšćina',
|
2014-12-19 17:58:50 +03:00
|
|
|
u'English': u'Serbian'},
|
|
|
|
u'en-US': {
|
|
|
|
u'native': u'English (US)',
|
|
|
|
u'English': u'English (US)'},
|
2017-08-23 12:06:30 +03:00
|
|
|
u'en-GB': {
|
|
|
|
u'native': u'English (GB)',
|
|
|
|
u'English': u'English (GB)'},
|
2014-12-19 17:58:50 +03:00
|
|
|
u'tr': {
|
2017-08-23 12:06:30 +03:00
|
|
|
u'native': u'Türkçe',
|
2014-12-19 17:58:50 +03:00
|
|
|
u'English': u'Turkish'},
|
|
|
|
u'cy': {
|
|
|
|
u'native': u'Cymraeg',
|
|
|
|
u'English': u'Welsh'},
|
|
|
|
u'sr-Latn': {
|
|
|
|
u'native': u'Srpski',
|
2017-05-23 09:34:01 +03:00
|
|
|
u'English': u'Serbian'},
|
2017-08-23 12:06:30 +03:00
|
|
|
u'es': {
|
|
|
|
u'native': u'Español',
|
|
|
|
u'English': u'Spanish'},
|
2017-05-23 09:34:01 +03:00
|
|
|
u'dbg': {
|
|
|
|
u'English': u'Debug Robot',
|
2017-08-23 12:06:30 +03:00
|
|
|
u'native': u'Ḓḗƀŭɠ Řǿƀǿŧ'}
|
|
|
|
})
|
2014-12-19 17:58:50 +03:00
|
|
|
|
|
|
|
product_details.product_details = MockProductDetails()
|