zulip_botserver: Remove unused imports and do some other cleanup.

This commit is contained in:
Guitar1st 2018-05-14 19:08:03 +00:00
parent 292a3bc067
commit 641665c338
3 changed files with 19 additions and 23 deletions

View file

@ -1,14 +1,15 @@
from unittest import TestCase
import zulip_botserver.server
import json
from typing import Any, List, Dict, Mapping, Optional
from typing import Any, List, Dict, Optional
from unittest import TestCase
from zulip_botserver import server
class BotServerTestCase(TestCase):
def setUp(self):
# type: () -> None
zulip_botserver.server.app.testing = True
self.app = zulip_botserver.server.app.test_client()
server.app.testing = True
self.app = server.app.test_client()
def assert_bot_server_response(self,
available_bots=None,
@ -21,14 +22,14 @@ class BotServerTestCase(TestCase):
):
# type: (Optional[List[str]], Optional[Dict[str, Any]], Optional[Dict[str, Any]], Optional[Dict[str, Any]], str, Dict[str, Dict[str, Any]], bool) -> None
if available_bots is not None:
zulip_botserver.server.available_bots = available_bots
zulip_botserver.server.bots_config = bots_config # type: ignore # monkey-patching
zulip_botserver.server.load_lib_modules()
zulip_botserver.server.load_bot_handlers()
server.available_bots = available_bots
server.bots_config = bots_config # type: ignore # monkey-patching
server.load_lib_modules()
server.load_bot_handlers()
response = self.app.post(payload_url, data=json.dumps(message))
if check_success:
assert response.status_code >= 200 and response.status_code < 300
assert 200 <= response.status_code < 300
else:
assert response.status_code >= 400 and response.status_code < 500
assert 400 <= response.status_code < 500

View file

@ -2,7 +2,6 @@ from __future__ import absolute_import
import mock
import unittest
from typing import Any
from zulip_botserver import server
from .server_test_lib import BotServerTestCase
import six

View file

@ -1,13 +1,11 @@
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import json
import argparse
from flask import Flask, request
from importlib import import_module
from typing import Any, Dict, Mapping, Union, List, Tuple
from typing import Any, Dict, Mapping, Union, List
from werkzeug.exceptions import BadRequest
from six.moves.configparser import SafeConfigParser
@ -122,19 +120,17 @@ def parse_args():
parser = argparse.ArgumentParser(usage=usage)
parser.add_argument('--config-file',
action='store',
help='(config file for the zulip bot server (flaskbotrc))')
required=True,
help='Config file for the zulip bot server (flaskbotrc)')
parser.add_argument('--hostname',
action='store',
default="127.0.0.1",
help='(address on which you want to run the server)')
help='Address on which you want to run the server')
parser.add_argument('--port',
action='store',
default=5002,
help='(port on which you want to run the server)')
options = parser.parse_args()
if not options.config_file: # if flaskbotrc is not given
parser.error('Flaskbotrc not given')
return options
help='Port on which you want to run the server')
return parser.parse_args()
def main():