Changeset View
Changeset View
Standalone View
Standalone View
swh/web/settings/tests.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
""" | """ | ||||
Django tests settings for swh-web. | Django tests settings for swh-web. | ||||
""" | """ | ||||
import os | |||||
import sys | import sys | ||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
scope1_limiter_rate = 3 | scope1_limiter_rate = 3 | ||||
scope1_limiter_rate_post = 1 | scope1_limiter_rate_post = 1 | ||||
scope2_limiter_rate = 5 | scope2_limiter_rate = 5 | ||||
scope2_limiter_rate_post = 2 | scope2_limiter_rate_post = 2 | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
DATABASES = { | DATABASES = { | ||||
'default': { | 'default': { | ||||
'ENGINE': 'django.db.backends.sqlite3', | 'ENGINE': 'django.db.backends.sqlite3', | ||||
'NAME': swh_web_config['test_db'], | 'NAME': swh_web_config['test_db'], | ||||
} | } | ||||
} | } | ||||
# when not running unit tests, make the webapp fetch data from memory storages | # when not running unit tests, make the webapp fetch data from memory storages | ||||
if 'pytest' not in sys.argv[0]: | if 'pytest' not in sys.argv[0] and 'PYTEST_XDIST_WORKER' not in os.environ: | ||||
swh_web_config.update({ | swh_web_config.update({ | ||||
'debug': True, | 'debug': True, | ||||
'e2e_tests_mode': True | 'e2e_tests_mode': True | ||||
}) | }) | ||||
from swh.web.tests.data import get_tests_data, override_storages # noqa | from swh.web.tests.data import get_tests_data, override_storages # noqa | ||||
test_data = get_tests_data() | test_data = get_tests_data() | ||||
override_storages(test_data['storage'], test_data['idx_storage'], | override_storages(test_data['storage'], test_data['idx_storage'], | ||||
test_data['search']) | test_data['search']) | ||||
else: | else: | ||||
ALLOWED_HOSTS += ['testserver'] | ALLOWED_HOSTS += ['testserver'] | ||||
# Silent DEBUG output when running unit tests | # Silent DEBUG output when running unit tests | ||||
LOGGING['handlers']['console']['level'] = 'INFO' # type: ignore | LOGGING['handlers']['console']['level'] = 'INFO' # type: ignore |