salesforce bot: Quit on invalid API key.

This commit is contained in:
Robert Hönig 2018-01-04 15:34:50 +01:00 committed by showell
parent 8417dbf154
commit 57342072dc
2 changed files with 3 additions and 8 deletions

View file

@ -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:

View file

@ -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 <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')