mirror of https://github.com/searxng/searxng.git
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# pylint: disable=missing-module-docstring
|
|
|
|
from parameterized import parameterized
|
|
from tests import SearxTestCase
|
|
import searx.exceptions
|
|
from searx import get_setting
|
|
|
|
|
|
class TestExceptions(SearxTestCase): # pylint: disable=missing-class-docstring
|
|
@parameterized.expand(
|
|
[
|
|
searx.exceptions.SearxEngineAccessDeniedException,
|
|
searx.exceptions.SearxEngineCaptchaException,
|
|
searx.exceptions.SearxEngineTooManyRequestsException,
|
|
]
|
|
)
|
|
def test_default_suspend_time(self, exception):
|
|
with self.assertRaises(exception) as e:
|
|
raise exception()
|
|
self.assertEqual(
|
|
e.exception.suspended_time,
|
|
get_setting(exception.SUSPEND_TIME_SETTING),
|
|
)
|
|
|
|
@parameterized.expand(
|
|
[
|
|
searx.exceptions.SearxEngineAccessDeniedException,
|
|
searx.exceptions.SearxEngineCaptchaException,
|
|
searx.exceptions.SearxEngineTooManyRequestsException,
|
|
]
|
|
)
|
|
def test_custom_suspend_time(self, exception):
|
|
with self.assertRaises(exception) as e:
|
|
raise exception(suspended_time=1337)
|
|
self.assertEqual(e.exception.suspended_time, 1337)
|