From 4285cef29cfc0d814d206f7481e058dd4f1b8a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Mon, 28 May 2018 17:50:55 +0200 Subject: [PATCH] assert_bot_server_response: Mock ExternalBotHandler. --- zulip_botserver/tests/server_test_lib.py | 3 +++ zulip_botserver/tests/test_server.py | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zulip_botserver/tests/server_test_lib.py b/zulip_botserver/tests/server_test_lib.py index cb365c5..2fb3538 100644 --- a/zulip_botserver/tests/server_test_lib.py +++ b/zulip_botserver/tests/server_test_lib.py @@ -1,5 +1,6 @@ import configparser import json +import mock from typing import Any, List, Dict, Optional from unittest import TestCase @@ -12,8 +13,10 @@ class BotServerTestCase(TestCase): server.app.testing = True self.app = server.app.test_client() + @mock.patch('zulip_bots.lib.ExternalBotHandler') def assert_bot_server_response( self, + mock_ExternalBotHandler: mock.Mock, available_bots: Optional[List[str]]=None, bots_config: Optional[Dict[str, Dict[str, str]]]=None, bot_handlers: Optional[Dict[str, Any]]=None, diff --git a/zulip_botserver/tests/test_server.py b/zulip_botserver/tests/test_server.py index 964922b..95c3cd4 100644 --- a/zulip_botserver/tests/test_server.py +++ b/zulip_botserver/tests/test_server.py @@ -19,8 +19,7 @@ class BotServerTests(BotServerTestCase): def handler_class(self) -> Any: return BotServerTests.MockMessageHandler() - @mock.patch('zulip_bots.lib.ExternalBotHandler') - def test_successful_request(self, mock_ExternalBotHandler: mock.Mock) -> None: + def test_successful_request(self) -> None: available_bots = ['helloworld'] bots_config = { 'helloworld': { @@ -35,8 +34,7 @@ class BotServerTests(BotServerTestCase): bot_email='helloworld-bot@zulip.com'), check_success=True) - @mock.patch('zulip_bots.lib.ExternalBotHandler') - def test_successful_request_from_two_bots(self, mock_ExternalBotHandler: mock.Mock) -> None: + def test_successful_request_from_two_bots(self) -> None: available_bots = ['helloworld', 'help'] bots_config = { 'helloworld': {