mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
bots: Test get_config_info with giphy bot.
This involves both using the new `initialize` method for calling `get_config_info`, and refactoring the testing framework by adding a way for mocking this method.
This commit is contained in:
@@ -52,6 +52,10 @@ class BotTestCase(TestCase):
|
||||
# type: () -> None
|
||||
self.patcher.stop()
|
||||
|
||||
def initialize_bot(self):
|
||||
# type: () -> None
|
||||
self.message_handler.initialize(self.MockClass())
|
||||
|
||||
def check_expected_responses(self, expectations, expected_method='send_reply',
|
||||
email="foo_sender@zulip.com", recipient="foo", subject="foo",
|
||||
type="all"):
|
||||
@@ -87,6 +91,13 @@ class BotTestCase(TestCase):
|
||||
else:
|
||||
instance.send_reply.assert_called_with(message, response['content'])
|
||||
|
||||
@contextmanager
|
||||
def mock_config_info(self, config_info):
|
||||
# type: (Dict[str, str]) -> Any
|
||||
self.MockClass.return_value.get_config_info.return_value = config_info
|
||||
yield
|
||||
self.MockClass.return_value.get_config_info.return_value = None
|
||||
|
||||
@contextmanager
|
||||
def mock_http_conversation(self, test_name):
|
||||
# type: (str) -> Any
|
||||
|
||||
Reference in New Issue
Block a user