salesforce bot: Quit on invalid API key.
MODIFY
zulip_bots/zulip_bots/bots/salesforce/salesforce.py
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:

MODIFY
zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py
zulip_bots/zulip_bots/bots/salesforce/test_salesforce.py
-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 <name> [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')

salesforce bot: Quit on invalid API key.