diff --git a/zulip_botserver/tests/test.conf b/zulip_botserver/tests/test.conf new file mode 100644 index 0000000..b59691f --- /dev/null +++ b/zulip_botserver/tests/test.conf @@ -0,0 +1,8 @@ +[helloworld] +key=value +email=helloworld-bot@zulip.com +site=http://localhost +[giphy] +key=value2 +email=giphy-bot@zulip.com +site=http://localhost diff --git a/zulip_botserver/tests/test_server.py b/zulip_botserver/tests/test_server.py index 54fefb7..e3b6243 100644 --- a/zulip_botserver/tests/test_server.py +++ b/zulip_botserver/tests/test_server.py @@ -1,9 +1,12 @@ import mock +import os from typing import Any, Dict import unittest from .server_test_lib import BotServerTestCase import six +import json +from zulip_botserver import server from zulip_botserver.input_parameters import parse_args @@ -83,6 +86,23 @@ class BotServerTests(BotServerTestCase): assert opts.hostname == '127.0.0.1' assert opts.port == 5002 + def test_read_config_file(self) -> None: + current_dir = os.path.dirname(os.path.abspath(__file__)) + bot_conf = server.read_config_file(os.path.join(current_dir, "test.conf")) + expected_config = { + 'helloworld': { + 'email': 'helloworld-bot@zulip.com', + 'key': 'value', + 'site': 'http://localhost', + }, + 'giphy': { + 'email': 'giphy-bot@zulip.com', + 'key': 'value2', + 'site': 'http://localhost', + } + } + assert json.dumps(bot_conf, sort_keys=True) == json.dumps(expected_config, sort_keys=True) + if __name__ == '__main__': unittest.main()