From f382875d5a0ca225a49027f34819b9991bda3cde Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Fri, 3 Nov 2017 21:08:34 +0100 Subject: [PATCH] embedded bots: Add full test coverage for queue processor. --- zerver/tests/test_embedded_bot_system.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zerver/tests/test_embedded_bot_system.py b/zerver/tests/test_embedded_bot_system.py index e8b9ba87a0..fa3840398c 100644 --- a/zerver/tests/test_embedded_bot_system.py +++ b/zerver/tests/test_embedded_bot_system.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +from unittest.mock import patch from typing import Any, Dict, Tuple, Text, Optional from zerver.lib.test_classes import ZulipTestCase @@ -44,3 +45,17 @@ class TestEmbeddedBotMessaging(ZulipTestCase): content="foo", topic_name="bar") last_message = self.get_last_message() self.assertEqual(last_message.content, "foo") + +class TestEmbeddedBotFailures(ZulipTestCase): + @patch("logging.error") + def test_invalid_embedded_bot_service(self, logging_error_mock): + # type: (mock.Mock) -> None + user_profile = self.example_user("othello") + bot_profile = self.create_test_bot('embedded-bot@zulip.testserver', user_profile, 'Embedded bot', + 'embedded', UserProfile.EMBEDDED_BOT, service_name='nonexistent_service') + mention_bot_message = "@**{}** foo".format(bot_profile.full_name) + self.send_stream_message(user_profile.email, "Denmark", + content=mention_bot_message, + topic_name="bar") + last_message = self.get_last_message() + self.assertEqual(last_message.content, mention_bot_message)