zulip_bots: Make xkcd bot error more verbose.
This commit is contained in:
parent
0eb285da29
commit
94b7c2eaef
|
@ -13,7 +13,7 @@ class TestXkcdBot(BotTestCase):
|
|||
@mock.patch('logging.exception')
|
||||
def test_bot(self, mock_logging_exception):
|
||||
help_txt = "xkcd bot supports these commands:"
|
||||
err_txt = "xkcd bot only supports these commands:"
|
||||
err_txt = "xkcd bot only supports these commands, not `{}`:"
|
||||
commands = '''
|
||||
* `@xkcd help` to show this help message.
|
||||
* `@xkcd latest` to fetch the latest comic strip from xkcd.
|
||||
|
@ -78,7 +78,7 @@ class TestXkcdBot(BotTestCase):
|
|||
)
|
||||
|
||||
# Empty query, no request made to the Internet.
|
||||
bot_response = err_txt+commands
|
||||
bot_response = err_txt.format('')+commands
|
||||
self.assert_bot_response(
|
||||
message = {'content': ''},
|
||||
response = {'content': bot_response},
|
||||
|
@ -94,7 +94,7 @@ class TestXkcdBot(BotTestCase):
|
|||
)
|
||||
|
||||
# wrong command.
|
||||
bot_response = err_txt+commands
|
||||
bot_response = err_txt.format('x')+commands
|
||||
self.assert_bot_response(
|
||||
message = {'content': 'x'},
|
||||
response = {'content': bot_response},
|
||||
|
|
|
@ -68,7 +68,7 @@ def get_xkcd_bot_response(message):
|
|||
elif command.isdigit():
|
||||
fetched = fetch_xkcd_query(XkcdBotCommand.COMIC_ID, command)
|
||||
else:
|
||||
return commands_help % ('xkcd bot only supports these commands:')
|
||||
return commands_help % ("xkcd bot only supports these commands, not `%s`:" % (command,))
|
||||
except (requests.exceptions.ConnectionError, XkcdServerError):
|
||||
logging.exception('Connection error occurred when trying to connect to xkcd server')
|
||||
return 'Sorry, I cannot process your request right now, please try again later!'
|
||||
|
|
Loading…
Reference in a new issue