diff --git a/zulip_bots/zulip_bots/bots/youtube/fixtures/test_unknown_error.json b/zulip_bots/zulip_bots/bots/youtube/fixtures/test_unknown_error.json new file mode 100644 index 0000000..d39d6c1 --- /dev/null +++ b/zulip_bots/zulip_bots/bots/youtube/fixtures/test_unknown_error.json @@ -0,0 +1,31 @@ +{ + "request": { + "api_url": "https://www.googleapis.com/youtube/v3/search", + "params": { + "part": "id,snippet", + "maxResults": 1, + "key": "12345678", + "q": "test", + "alt": "json", + "type": "video", + "regionCode": "US" + } + }, + "response": { + "error": { + "errors": [ + { + "domain": "error", + "reason": "unknownError", + "message": "Unknown Rrror" + } + ], + "code": 400, + "message": "Bad Request" + } + }, + "response-headers": { + "status": 400, + "content-type": "application/json; charset=utf-8" + } + } diff --git a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py index 163bc98..d527fc2 100644 --- a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py @@ -43,6 +43,15 @@ class TestYoutubeBot(BotTestCase, DefaultTests): self.assertRaises(bot_handler.BotQuitException): bot.initialize(bot_handler) + def test_unknown_error(self) -> None: + bot = get_bot_message_handler(self.bot_name) + bot_handler = StubBotHandler() + + with self.mock_config_info(self.normal_config), \ + self.mock_http_conversation('test_unknown_error'), \ + self.assertRaises(HTTPError): + bot.initialize(bot_handler) + def test_multiple(self) -> None: bot = get_bot_message_handler(self.bot_name) bot_handler = StubBotHandler()