From f4bea72557be1f7c7b9cff18a3ed9e1d7173b58d Mon Sep 17 00:00:00 2001 From: novokrest Date: Fri, 8 Jun 2018 00:23:27 +0300 Subject: [PATCH] youtube: Add test for unknown error during `initialize`. --- .../youtube/fixtures/test_unknown_error.json | 31 +++++++++++++++++++ .../zulip_bots/bots/youtube/test_youtube.py | 9 ++++++ 2 files changed, 40 insertions(+) create mode 100644 zulip_bots/zulip_bots/bots/youtube/fixtures/test_unknown_error.json 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()