Skip to content

Commit bda4b74

Browse files
committed
mention bot: Add fixture for invalid api key test.
This makes the mention bot tests no longer rely on an internet connection to succeed.
1 parent 4ed31eb commit bda4b74

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"request": {
3+
"api_url": "https://api.mention.net/api/accounts/me",
4+
"headers": {
5+
"Authorization": "Bearer TEST",
6+
"Accept-Version": "1.15"
7+
}
8+
},
9+
"response": {
10+
"error_description": "The access token provided is invalid.",
11+
"error": "invalid_grant"
12+
},
13+
"response-headers": {
14+
"X-Protected-By":"Sqreen",
15+
"X-Content-Type-Options":"nosniff",
16+
"Transfer-Encoding":"chunked",
17+
"Cache-Control":"no-store, private",
18+
"WWW-Authenticate":"Bearer realm=\"Service\", error=\"invalid_grant\", error_description=\"The access token provided is invalid.\"",
19+
"Set-Cookie":"www_bucket=23; Expires=Thu, 08 Mar 2018 14:08:36 GMT; Domain=mention.com; Path=/",
20+
"Vary":"Accept-Language, X-Accept-Language",
21+
"X-Upstream2":"mention_backend",
22+
"X-Frame-Options":"SAMEORIGIN",
23+
"Connection":"keep-alive",
24+
"Content-Type":"application/json",
25+
"Referrer-Policy":"same-origin",
26+
"X-XSS-Protection":"1; mode=block",
27+
"Pragma":"no-cache",
28+
"Date":"Tue, 06 Feb 2018 14:08:36 GMT",
29+
"Server":"nginx",
30+
"X-S":"web14"
31+
}
32+
}

zulip_bots/zulip_bots/bots/mention/test_mention.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ def test_exception_when_api_key_is_invalid(self) -> None:
4949
bot_test_instance = MentionHandler()
5050

5151
with self.mock_config_info({'access_token': 'TEST'}):
52-
with self.assertRaises(StubBotHandler.BotQuitException):
53-
bot_test_instance.initialize(StubBotHandler())
52+
with self.mock_http_conversation('invalid_api_key'):
53+
with self.assertRaises(StubBotHandler.BotQuitException):
54+
bot_test_instance.initialize(StubBotHandler())

0 commit comments

Comments
 (0)