botserver: Strip messages like we do in zulip-run-bot.

Previously, messages weren't stripped at all. This
caused most bots to break and send replies similar to
"I didn't understand your command". Nobody noticed,
because the tests were only validating that replies
were sent, but not the content in them. Thus, this
commit also adds tests to avoid further regressions.
This commit is contained in:
Robert Hönig 2018-05-28 17:06:57 +02:00
parent f1bcf3b9a4
commit e6ef34a964
3 changed files with 27 additions and 11 deletions

View file

@ -30,8 +30,9 @@ class BotServerTests(BotServerTestCase):
}
self.assert_bot_server_response(available_bots=available_bots,
bots_config=bots_config,
event=dict(message={'content': "test message"},
bot_email='helloworld-bot@zulip.com'),
event=dict(message={'content': "@**test** test message"},
bot_email='helloworld-bot@zulip.com',
trigger='mention'),
expected_response="beep boop",
check_success=True)
@ -50,8 +51,9 @@ class BotServerTests(BotServerTestCase):
}
}
self.assert_bot_server_response(available_bots=available_bots,
event=dict(message={'content': "test message"},
bot_email='helloworld-bot@zulip.com'),
event=dict(message={'content': "@**test** test message"},
bot_email='helloworld-bot@zulip.com',
trigger='mention'),
expected_response="beep boop",
bots_config=bots_config,
check_success=True)
@ -89,8 +91,9 @@ class BotServerTests(BotServerTestCase):
"make sure you have set up the flaskbotrc file correctly.",
lambda: self.assert_bot_server_response(
available_bots=available_bots,
event=dict(message={'content': "test message"},
bot_email='helloworld-bot@zulip.com'),
event=dict(message={'content': "@**test** test message"},
bot_email='helloworld-bot@zulip.com',
trigger='mention'),
bots_config=bots_config))
@mock.patch('sys.argv', ['zulip-bot-server', '--config-file', '/foo/bar/baz.conf'])