From 79899dba30fe42ba2704a7e0911971f292b40ad3 Mon Sep 17 00:00:00 2001 From: dkvasov Date: Thu, 17 May 2018 19:16:18 +0300 Subject: [PATCH] zulip_botserver: More test cases. --- zulip_botserver/tests/test_server.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/zulip_botserver/tests/test_server.py b/zulip_botserver/tests/test_server.py index e3b6243..0513747 100644 --- a/zulip_botserver/tests/test_server.py +++ b/zulip_botserver/tests/test_server.py @@ -87,9 +87,11 @@ class BotServerTests(BotServerTestCase): assert opts.port == 5002 def test_read_config_file(self) -> None: + with self.assertRaises(IOError): + server.read_config_file("nonexistentfile.conf") current_dir = os.path.dirname(os.path.abspath(__file__)) - bot_conf = server.read_config_file(os.path.join(current_dir, "test.conf")) - expected_config = { + bot_conf1 = server.read_config_file(os.path.join(current_dir, "test.conf")) + expected_config1 = { 'helloworld': { 'email': 'helloworld-bot@zulip.com', 'key': 'value', @@ -101,7 +103,16 @@ class BotServerTests(BotServerTestCase): 'site': 'http://localhost', } } - assert json.dumps(bot_conf, sort_keys=True) == json.dumps(expected_config, sort_keys=True) + assert json.dumps(bot_conf1, sort_keys=True) == json.dumps(expected_config1, sort_keys=True) + bot_conf2 = server.read_config_file(os.path.join(current_dir, "test.conf"), "redefined_bot") + expected_config2 = { + 'redefined_bot': { + 'email': 'helloworld-bot@zulip.com', + 'key': 'value', + 'site': 'http://localhost', + } + } + assert json.dumps(bot_conf2, sort_keys=True) == json.dumps(expected_config2, sort_keys=True) if __name__ == '__main__':