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 mock
|
||||||
|
import os
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
import unittest
|
import unittest
|
||||||
from .server_test_lib import BotServerTestCase
|
from .server_test_lib import BotServerTestCase
|
||||||
import six
|
import six
|
||||||
|
import json
|
||||||
|
|
||||||
|
from zulip_botserver import server
|
||||||
from zulip_botserver.input_parameters import parse_args
|
from zulip_botserver.input_parameters import parse_args
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +86,23 @@ class BotServerTests(BotServerTestCase):
|
||||||
assert opts.hostname == '127.0.0.1'
|
assert opts.hostname == '127.0.0.1'
|
||||||
assert opts.port == 5002
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue