zulip_botserver: Add test for config parsing.
This commit is contained in:
parent
40785d3116
commit
fe801d08eb
8
zulip_botserver/tests/test.conf
Normal file
8
zulip_botserver/tests/test.conf
Normal file
|
@ -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
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue