From 935701aea2e5fabc8ebfb9536141d31d5e91e896 Mon Sep 17 00:00:00 2001 From: novokrest Date: Sun, 10 Jun 2018 22:33:15 +0300 Subject: [PATCH] flock: Add test for connection error during message sending. --- zulip_bots/zulip_bots/bots/flock/test_flock.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zulip_bots/zulip_bots/bots/flock/test_flock.py b/zulip_bots/zulip_bots/bots/flock/test_flock.py index 251cc23..fdf36a0 100644 --- a/zulip_bots/zulip_bots/bots/flock/test_flock.py +++ b/zulip_bots/zulip_bots/bots/flock/test_flock.py @@ -49,6 +49,15 @@ right now.\nPlease try again later") self.mock_http_conversation('test_found_invalid_recipient'): self.verify_reply('david: hello', bot_response) + @patch('zulip_bots.bots.flock.flock.get_recipient_id') + def test_message_send_connection_error(self, get_recipient_id: str) -> None: + bot_response = "Uh-Oh, couldn't process the request right now.\nPlease try again later" + get_recipient_id.return_value = ["u:userid", None] + with self.mock_config_info(self.normal_config), \ + patch('requests.get', side_effect=ConnectionError()), \ + patch('logging.exception'): + self.verify_reply('Rishabh: hi there', bot_response) + @patch('zulip_bots.bots.flock.flock.get_recipient_id') def test_message_send_success(self, get_recipient_id: str) -> None: bot_response = "Message sent."