Changeset View
Changeset View
Standalone View
Standalone View
swh/web/settings/tests.py
# Copyright (C) 2017-2018 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 sys | |||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
from swh.web.tests.data import get_tests_data, override_storages | |||||
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 | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | 'throttling': { | ||||
'POST': '%s/min' % scope3_limiter_rate_post | 'POST': '%s/min' % scope3_limiter_rate_post | ||||
}, | }, | ||||
'exempted_networks': ['127.0.0.0/8'] | 'exempted_networks': ['127.0.0.0/8'] | ||||
} | } | ||||
} | } | ||||
} | } | ||||
}) | }) | ||||
from .common import * # noqa | from .common import * # noqa | ||||
from .common import ALLOWED_HOSTS, LOGGING # noqa | from .common import ALLOWED_HOSTS, LOGGING # noqa | ||||
# when not running unit tests, make the webapp fetch data from memory storages | |||||
if 'pytest' not in sys.argv[0]: | |||||
swh_web_config.update({ | |||||
'debug': True, | |||||
'grecaptcha': { | |||||
'activated': False, | |||||
'site_key': '', | |||||
'private_key': '' | |||||
} | |||||
}) | |||||
test_data = get_tests_data() | |||||
override_storages(test_data['storage'], test_data['idx_storage']) | |||||
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' | LOGGING['handlers']['console']['level'] = 'INFO' |