diff --git a/zulip_bots/zulip_bots/bots/salesforce/salesforce.py b/zulip_bots/zulip_bots/bots/salesforce/salesforce.py index da42f65..94357fe 100644 --- a/zulip_bots/zulip_bots/bots/salesforce/salesforce.py +++ b/zulip_bots/zulip_bots/bots/salesforce/salesforce.py @@ -163,9 +163,7 @@ class SalesforceHandler(object): security_token=self.config_info['security_token'] ) except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err: - logging.error( - 'Failed to log in to Salesforce. {} {}'.format(err.code, err.message)) - quit() + bot_handler.quit('Failed to log in to Salesforce. {} {}'.format(err.code, err.message)) def handle_message(self, message: Any, bot_handler: Any) -> None: try: diff --git a/zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py b/zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py index 7f8ac14..e33def3 100644 --- a/zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py +++ b/zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py @@ -1,4 +1,4 @@ -from zulip_bots.test_lib import BotTestCase, read_bot_fixture_data +from zulip_bots.test_lib import BotTestCase, StubBotHandler, read_bot_fixture_data import simple_salesforce from simple_salesforce.exceptions import SalesforceAuthenticationFailed from contextlib import contextmanager @@ -174,11 +174,8 @@ class TestSalesforceBot(BotTestCase): 'Usage: find contact [arguments]') def test_bad_auth(self) -> None: - with self.assertLogs(level='ERROR') as log, \ - patch('builtins.quit'): + with self.assertRaises(StubBotHandler.BotQuitException): self._test_initialize(auth_success=False) - self.assertIn( - 'ERROR:root:Failed to log in to Salesforce. 403 auth failed', log.output) def test_callback(self) -> None: self._test('test_one_result', 'echo hello', 'hello')