zulip_botserver: Make tests more realistic.

Specifically, this invokes server.load_lib_modules()
and server.load_bot_handlers() to generate the modules
and handlers, instead of hardcoding them.
This commit is contained in:
derAnfaenger 2017-11-07 13:17:32 +01:00 committed by Tim Abbott
parent 55332d8cbc
commit fb116259d0
2 changed files with 10 additions and 26 deletions

View file

@ -15,23 +15,16 @@ class BotServerTestCase(TestCase):
bots_config=None,
bots_lib_module=None,
bot_handlers=None,
payload_url="/bots/testbot",
payload_url="/bots/helloworld",
message=dict(message={'key': "test message"}),
check_success=False,
):
# type: (List[str], Dict[str, Any], Dict[str, Any], Dict[str, Any], str, Dict[str, Dict[str, Any]], bool) -> None
if available_bots is not None:
zulip_botserver.server.available_bots = available_bots
if bots_config is not None:
zulip_botserver.server.bots_config = bots_config
if bots_lib_module is not None:
zulip_botserver.server.bots_lib_module = bots_lib_module
if bot_handlers is not None:
zulip_botserver.server.bot_handlers = bot_handlers
zulip_botserver.server.load_lib_modules()
zulip_botserver.server.load_bot_handlers()
response = self.app.post(payload_url, data=json.dumps(message))