flask_server: Move the server to its own package.
This commit is contained in:
parent
9d1253ff0d
commit
928d5ca16d
7 changed files with 96 additions and 10 deletions
37
zulip_botserver/tests/server_test_lib.py
Normal file
37
zulip_botserver/tests/server_test_lib.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from unittest import TestCase
|
||||
import zulip_botserver.server
|
||||
import json
|
||||
from typing import Any, List, Dict, Mapping
|
||||
|
||||
class BotServerTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
zulip_botserver.server.app.testing = True
|
||||
self.app = zulip_botserver.server.app.test_client()
|
||||
|
||||
def assert_bot_server_response(self,
|
||||
available_bots=None,
|
||||
bots_config=None,
|
||||
bots_lib_module=None,
|
||||
payload_url="/bots/testbot",
|
||||
message=dict(message={'key': "test message"}),
|
||||
check_success=False,
|
||||
):
|
||||
# type: (List[str], 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
|
||||
|
||||
response = self.app.post(payload_url, data=json.dumps(message))
|
||||
|
||||
if check_success:
|
||||
assert response.status_code >= 200 and response.status_code < 300
|
||||
else:
|
||||
assert response.status_code >= 400 and response.status_code < 500
|
Loading…
Add table
Add a link
Reference in a new issue