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:
Robert Hönig
2017-06-10 19:33:22 +02:00
committed by Tim Abbott
parent 027f344f7e
commit 790240cc57
3 changed files with 23 additions and 12 deletions

View File

@@ -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