google_translate bot: Add test for invalid api key.
ADD
zulip_bots/zulip_bots/bots/google_translate/fixtures/test_invalid_api_key.json
+{
+ "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"
+ }
+}

MODIFY
zulip_bots/zulip_bots/bots/google_translate/test_google_translate.py
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')

google_translate bot: Add test for invalid api key.