assert_bot_server_response: Mock ExternalBotHandler.

This commit is contained in:
Robert Hönig 2018-05-28 17:50:55 +02:00 committed by Tim Abbott
parent 27938a926b
commit 4285cef29c
2 changed files with 5 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import configparser import configparser
import json import json
import mock
from typing import Any, List, Dict, Optional from typing import Any, List, Dict, Optional
from unittest import TestCase from unittest import TestCase
@ -12,8 +13,10 @@ class BotServerTestCase(TestCase):
server.app.testing = True server.app.testing = True
self.app = server.app.test_client() self.app = server.app.test_client()
@mock.patch('zulip_bots.lib.ExternalBotHandler')
def assert_bot_server_response( def assert_bot_server_response(
self, self,
mock_ExternalBotHandler: mock.Mock,
available_bots: Optional[List[str]]=None, available_bots: Optional[List[str]]=None,
bots_config: Optional[Dict[str, Dict[str, str]]]=None, bots_config: Optional[Dict[str, Dict[str, str]]]=None,
bot_handlers: Optional[Dict[str, Any]]=None, bot_handlers: Optional[Dict[str, Any]]=None,

View file

@ -19,8 +19,7 @@ class BotServerTests(BotServerTestCase):
def handler_class(self) -> Any: def handler_class(self) -> Any:
return BotServerTests.MockMessageHandler() return BotServerTests.MockMessageHandler()
@mock.patch('zulip_bots.lib.ExternalBotHandler') def test_successful_request(self) -> None:
def test_successful_request(self, mock_ExternalBotHandler: mock.Mock) -> None:
available_bots = ['helloworld'] available_bots = ['helloworld']
bots_config = { bots_config = {
'helloworld': { 'helloworld': {
@ -35,8 +34,7 @@ class BotServerTests(BotServerTestCase):
bot_email='helloworld-bot@zulip.com'), bot_email='helloworld-bot@zulip.com'),
check_success=True) check_success=True)
@mock.patch('zulip_bots.lib.ExternalBotHandler') def test_successful_request_from_two_bots(self) -> None:
def test_successful_request_from_two_bots(self, mock_ExternalBotHandler: mock.Mock) -> None:
available_bots = ['helloworld', 'help'] available_bots = ['helloworld', 'help']
bots_config = { bots_config = {
'helloworld': { 'helloworld': {