mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Remove timeout parameter in do_rest_call().
Nobody was setting it.
This commit is contained in:
@@ -260,10 +260,9 @@ def process_success_response(event: Dict[str, Any],
|
|||||||
def do_rest_call(base_url: str,
|
def do_rest_call(base_url: str,
|
||||||
request_data: Any,
|
request_data: Any,
|
||||||
event: Dict[str, Any],
|
event: Dict[str, Any],
|
||||||
service_handler: Any,
|
service_handler: Any) -> None:
|
||||||
timeout: Any=None) -> None:
|
|
||||||
try:
|
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'):
|
if str(response.status_code).startswith('2'):
|
||||||
process_success_response(event, service_handler, response)
|
process_success_response(event, service_handler, response)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class DoRestCallTests(ZulipTestCase):
|
|||||||
def test_successful_request(self, mock_send: mock.Mock) -> None:
|
def test_successful_request(self, mock_send: mock.Mock) -> None:
|
||||||
response = ResponseMock(200)
|
response = ResponseMock(200)
|
||||||
with mock.patch('requests.request', return_value=response):
|
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)
|
self.assertTrue(mock_send.called)
|
||||||
|
|
||||||
def test_retry_request(self: mock.Mock) -> None:
|
def test_retry_request(self: mock.Mock) -> None:
|
||||||
@@ -73,7 +73,7 @@ class DoRestCallTests(ZulipTestCase):
|
|||||||
|
|
||||||
self.mock_event['failed_tries'] = 3
|
self.mock_event['failed_tries'] = 3
|
||||||
with mock.patch('requests.request', return_value=response):
|
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()
|
bot_owner_notification = self.get_last_message()
|
||||||
self.assertEqual(bot_owner_notification.content,
|
self.assertEqual(bot_owner_notification.content,
|
||||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/subject/Foo/near/) triggered an outgoing webhook.
|
'''[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:
|
def test_fail_request(self, mock_fail_with_message: mock.Mock) -> None:
|
||||||
response = ResponseMock(400)
|
response = ResponseMock(400)
|
||||||
with mock.patch('requests.request', return_value=response):
|
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()
|
bot_owner_notification = self.get_last_message()
|
||||||
self.assertTrue(mock_fail_with_message.called)
|
self.assertTrue(mock_fail_with_message.called)
|
||||||
self.assertEqual(bot_owner_notification.content,
|
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:
|
def helper(side_effect: Any, error_text: str) -> None:
|
||||||
with mock.patch('logging.info'):
|
with mock.patch('logging.info'):
|
||||||
with mock.patch('requests.request', side_effect=side_effect):
|
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()
|
bot_owner_notification = self.get_last_message()
|
||||||
self.assertIn(error_text, bot_owner_notification.content)
|
self.assertIn(error_text, bot_owner_notification.content)
|
||||||
self.assertIn('triggered', 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')
|
@mock.patch('zerver.lib.outgoing_webhook.fail_with_message')
|
||||||
def test_request_exception(self, mock_fail_with_message: mock.Mock,
|
def test_request_exception(self, mock_fail_with_message: mock.Mock,
|
||||||
mock_requests_request: mock.Mock, mock_logger: mock.Mock) -> None:
|
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()
|
bot_owner_notification = self.get_last_message()
|
||||||
self.assertTrue(mock_fail_with_message.called)
|
self.assertTrue(mock_fail_with_message.called)
|
||||||
self.assertEqual(bot_owner_notification.content,
|
self.assertEqual(bot_owner_notification.content,
|
||||||
|
|||||||
Reference in New Issue
Block a user