diff --git a/zulip_bots/zulip_bots/bots/google_translate/fixtures/test_invalid_api_key.json b/zulip_bots/zulip_bots/bots/google_translate/fixtures/test_invalid_api_key.json new file mode 100644 index 0000000..1d0d64b --- /dev/null +++ b/zulip_bots/zulip_bots/bots/google_translate/fixtures/test_invalid_api_key.json @@ -0,0 +1,28 @@ +{ + "request": { + "method": "GET", + "api_url": "https://translation.googleapis.com/language/translate/v2/languages", + "params": { + "key": "abcdefg", + "target": "en" + } + }, + "response": { + "error":{ + "status": "INVALID_ARGUMENT", + "message": "API key not valid. Please pass a valid API key.", + "code": 400, + "errors": [ + { + "domain":"global", + "message":"API key not valid. Please pass a valid API key.", + "reason":"badRequest" + } + ] + } + }, + "response-headers": { + "status": 400, + "content-type": "application/json; charset=utf-8" + } +} diff --git a/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py b/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py index fee52bf..b39997b 100644 --- a/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py +++ b/zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py @@ -66,6 +66,10 @@ class TestGoogleTranslateBot(BotTestCase): side_effect=Exception): self._test('"hello" de', 'Error. .', 'test_languages') + def test_invalid_api_key(self): + with self.assertRaises(StubBotHandler.BotQuitException): + self._test(None, None, 'test_invalid_api_key') + def test_api_access_not_configured(self): with self.assertRaises(StubBotHandler.BotQuitException): self._test(None, None, 'test_api_access_not_configured')