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 os | ||||
import sys | import sys | ||||
from swh.web.config import SWH_WEB_INTERNAL_SERVER_NAME, 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 | ||||
scope3_limiter_rate = 1 | scope3_limiter_rate = 1 | ||||
scope3_limiter_rate_post = 1 | scope3_limiter_rate_post = 1 | ||||
save_origin_rate_post = 10 | save_origin_rate_post = 10 | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | swh_web_config.update( | ||||
"realm_name": "SoftwareHeritage", | "realm_name": "SoftwareHeritage", | ||||
}, | }, | ||||
} | } | ||||
) | ) | ||||
from .common import * # noqa | from .common import * # noqa | ||||
from .common import ALLOWED_HOSTS, LOGGING # noqa, isort: skip | from .common import LOGGING # noqa, isort: skip | ||||
ALLOWED_HOSTS = ["*"] | |||||
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] and "PYTEST_XDIST_WORKER" not in os.environ: | if "pytest" not in sys.argv[0] and "PYTEST_XDIST_WORKER" not in os.environ: | ||||
swh_web_config.update({"debug": True, "e2e_tests_mode": True}) | swh_web_config.update({"debug": True, "e2e_tests_mode": True}) | ||||
from swh.web.tests.data import get_tests_data, override_storages | from swh.web.tests.data import get_tests_data, override_storages | ||||
test_data = get_tests_data() | test_data = get_tests_data() | ||||
override_storages( | override_storages( | ||||
test_data["storage"], | test_data["storage"], | ||||
test_data["idx_storage"], | test_data["idx_storage"], | ||||
test_data["search"], | test_data["search"], | ||||
test_data["counters"], | test_data["counters"], | ||||
) | ) | ||||
else: | else: | ||||
ALLOWED_HOSTS += ["testserver", SWH_WEB_INTERNAL_SERVER_NAME] | |||||
ALLOWED_HOSTS += get_config()["staging_server_names"] | |||||
# Silent DEBUG output when running unit tests | # Silent DEBUG output when running unit tests | ||||
anlambert: I guess you can remove these lines now. | |||||
LOGGING["handlers"]["console"]["level"] = "INFO" # type: ignore | LOGGING["handlers"]["console"]["level"] = "INFO" # type: ignore |
I guess you can remove these lines now.