mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 15:00:16 +02:00
Fix tests
Thanks to @ErikKalkoken for helping here
This commit is contained in:
parent
49548d6f9f
commit
b6d6c68e54
@ -310,7 +310,23 @@ class TestFetchListFromGitlab(TestCase):
|
|||||||
self.assertEqual(requests_mocker.call_count, max_pages)
|
self.assertEqual(requests_mocker.call_count, max_pages)
|
||||||
|
|
||||||
@requests_mock.mock()
|
@requests_mock.mock()
|
||||||
def test_can_handle_connection_timeout(self, requests_mocker):
|
@patch(MODULE_PATH + '.admin_status.logger')
|
||||||
requests_mocker.get(self.url, exc=requests.exceptions.ConnectTimeout)
|
def test_should_not_raise_any_exception_from_github_request_but_log_as_warning(
|
||||||
with self.assertRaises(requests.exceptions.ConnectTimeout):
|
self, requests_mocker, mock_logger
|
||||||
|
):
|
||||||
|
for my_exception in [
|
||||||
|
requests.exceptions.ConnectionError,
|
||||||
|
requests.exceptions.HTTPError,
|
||||||
|
requests.exceptions.URLRequired,
|
||||||
|
requests.exceptions.TooManyRedirects,
|
||||||
|
requests.exceptions.ConnectTimeout,
|
||||||
|
requests.exceptions.Timeout,
|
||||||
|
|
||||||
|
]:
|
||||||
|
requests_mocker.get(self.url, exc=my_exception)
|
||||||
|
try:
|
||||||
result = _fetch_list_from_gitlab(self.url)
|
result = _fetch_list_from_gitlab(self.url)
|
||||||
|
except Exception as ex:
|
||||||
|
self.fail(f"Unexpected exception raised: {ex}")
|
||||||
|
self.assertTrue(mock_logger.warning.called)
|
||||||
|
self.assertListEqual(result, [])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user