mirror of https://github.com/zulip/zulip.git
Remove timeout parameter in do_rest_call().
Nobody was setting it.
This commit is contained in:
parent
69ee84bb14
commit
31597cf33e
|
@ -260,10 +260,9 @@ def process_success_response(event: Dict[str, Any],
|
|||
def do_rest_call(base_url: str,
|
||||
request_data: Any,
|
||||
event: Dict[str, Any],
|
||||
service_handler: Any,
|
||||
timeout: Any=None) -> None:
|
||||
service_handler: Any) -> None:
|
||||
try:
|
||||
response = requests.request('POST', base_url, data=request_data, timeout=timeout)
|
||||
response = requests.request('POST', base_url, data=request_data)
|
||||
if str(response.status_code).startswith('2'):
|
||||
process_success_response(event, service_handler, response)
|
||||
else:
|
||||
|
|
|
@ -65,7 +65,7 @@ class DoRestCallTests(ZulipTestCase):
|
|||
def test_successful_request(self, mock_send: mock.Mock) -> None:
|
||||
response = ResponseMock(200)
|
||||
with mock.patch('requests.request', return_value=response):
|
||||
do_rest_call('', None, self.mock_event, service_handler, None)
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
self.assertTrue(mock_send.called)
|
||||
|
||||
def test_retry_request(self: mock.Mock) -> None:
|
||||
|
@ -73,7 +73,7 @@ class DoRestCallTests(ZulipTestCase):
|
|||
|
||||
self.mock_event['failed_tries'] = 3
|
||||
with mock.patch('requests.request', return_value=response):
|
||||
do_rest_call('', None, self.mock_event, service_handler, None)
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/subject/Foo/near/) triggered an outgoing webhook.
|
||||
|
@ -85,7 +85,7 @@ The webhook got a response with status code *500*.''')
|
|||
def test_fail_request(self, mock_fail_with_message: mock.Mock) -> None:
|
||||
response = ResponseMock(400)
|
||||
with mock.patch('requests.request', return_value=response):
|
||||
do_rest_call('', None, self.mock_event, service_handler, None)
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertTrue(mock_fail_with_message.called)
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
|
@ -97,7 +97,7 @@ The webhook got a response with status code *400*.''')
|
|||
def helper(side_effect: Any, error_text: str) -> None:
|
||||
with mock.patch('logging.info'):
|
||||
with mock.patch('requests.request', side_effect=side_effect):
|
||||
do_rest_call('', None, self.mock_event, service_handler, None)
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertIn(error_text, bot_owner_notification.content)
|
||||
self.assertIn('triggered', bot_owner_notification.content)
|
||||
|
@ -111,7 +111,7 @@ The webhook got a response with status code *400*.''')
|
|||
@mock.patch('zerver.lib.outgoing_webhook.fail_with_message')
|
||||
def test_request_exception(self, mock_fail_with_message: mock.Mock,
|
||||
mock_requests_request: mock.Mock, mock_logger: mock.Mock) -> None:
|
||||
do_rest_call('', None, self.mock_event, service_handler, None)
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertTrue(mock_fail_with_message.called)
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
|
|
Loading…
Reference in New Issue