bot tests: import patch in incrementor & monkeytestit as in other tests.

This makes the code more compact and consistent.
This commit is contained in:
neiljp (Neil Pilgrim) 2018-06-09 20:39:03 -07:00 committed by showell
parent cd76a3cf5a
commit 0ea49c96ed
2 changed files with 7 additions and 6 deletions

View file

@ -1,4 +1,4 @@
from unittest import mock
from unittest.mock import patch
from zulip_bots.test_lib import (
get_bot_message_handler,
@ -19,7 +19,7 @@ class TestIncrementorBot(BotTestCase, DefaultTests):
bot.initialize(bot_handler)
bot.handle_message(message, bot_handler)
with mock.patch('zulip_bots.simple_lib.SimpleMessageServer.update') as m:
with patch('zulip_bots.simple_lib.SimpleMessageServer.update') as m:
bot.handle_message(message, bot_handler)
bot.handle_message(message, bot_handler)
bot.handle_message(message, bot_handler)

View file

@ -1,4 +1,5 @@
from unittest import mock, skipIf
from unittest.mock import patch
from unittest import skipIf
from sys import version_info
@ -18,7 +19,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='',
type='stream',
)
with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
res = self.get_response(message)
self.assertTrue("Unknown command" in res['content'])
@ -28,7 +29,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='check https://website.com',
type='stream',
)
with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
with self.mock_http_conversation('website_result_fail'):
res = self.get_response(message)
@ -39,7 +40,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='check https://website.com',
type='stream',
)
with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
with self.mock_http_conversation('website_result_success'):
res = self.get_response(message)