zulip_botserver: Test for import error with wrong credentials.
This commit is contained in:
parent
bf72a8994a
commit
fa9e5a8e26
|
@ -40,18 +40,21 @@ class BotServerTests(BotServerTestCase):
|
||||||
@mock.patch('logging.error')
|
@mock.patch('logging.error')
|
||||||
def test_wrong_bot_credentials(self, mock_LoggingError):
|
def test_wrong_bot_credentials(self, mock_LoggingError):
|
||||||
# type: (mock.Mock) -> None
|
# type: (mock.Mock) -> None
|
||||||
available_bots = ['helloworld']
|
available_bots = ['nonexistent-bot']
|
||||||
bots_config = {
|
bots_config = {
|
||||||
'helloworld': {
|
'nonexistent-bot': {
|
||||||
'email': 'helloworld-bot@zulip.com',
|
'email': 'helloworld-bot@zulip.com',
|
||||||
'key': '123456789qwertyuiop',
|
'key': '123456789qwertyuiop',
|
||||||
'site': 'http://localhost',
|
'site': 'http://localhost',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server.available_bots = available_bots
|
# This complains about mismatching argument types, yet they are all correct?
|
||||||
server.load_bot_handlers()
|
# We should investigate and file an issue in mypy.
|
||||||
mock_LoggingError.assert_called_with("Cannot fetch user profile, make sure you have set up the zuliprc file correctly.")
|
self.assertRaisesRegexp(ImportError, # type: ignore
|
||||||
|
"Bot \"nonexistent-bot\" doesn't exists. Please "
|
||||||
|
"make sure you have set up the flaskbotrc file correctly.",
|
||||||
|
lambda: self.assert_bot_server_response(available_bots=available_bots,
|
||||||
|
bots_config=bots_config))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue