Skip to content

Commit 4ed31eb

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

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"request": {
3+
"api_url": "https://api.baremetrics.com/v1/account",
4+
"headers": {
5+
"Authorization": "Bearer TEST"
6+
}
7+
},
8+
"response": {
9+
"error": "Unauthorized. Token not found (001)"
10+
},
11+
"response-headers": {
12+
"Cache-Control":"no-cache",
13+
"X-Version":"751",
14+
"X-Runtime":"0.003459",
15+
"Access-Control-Allow-Methods":"GET, OPTIONS, POST, PUT, DELETE",
16+
"Transfer-Encoding":"chunked",
17+
"Date":"Tue, 06 Feb 2018 14:00:34 GMT",
18+
"Connection":"keep-alive",
19+
"CF-RAY":"3e8ea2ed2dbe3de4-PRG",
20+
"Access-Control-Allow-Credentials":"false",
21+
"Content-Type":"application/json; charset=utf-8",
22+
"Set-Cookie":"__cfduid=d17cabc42559cc2d84e59a61d199208c11517925634; expires=Wed, 06-Feb-19 14:00:34 GMT; path=/; domain=.baremetrics.com; HttpOnly; Secure, LSW_WEB=\"LSW_WEB1\"; path=/",
23+
"Access-Control-Allow-Headers":"Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type",
24+
"X-Request-Id":"4c6d2ef3-2b72-4b7a-b535-991ee8c06fba",
25+
"X-Commit":"f5e0698f0a82d2d5040eb00762ff69f6d633eb50",
26+
"X-Powered-By":"Phusion Passenger 5.1.11",
27+
"Expect-CT":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
28+
"Server":"cloudflare",
29+
"Status":"401 Unauthorized"
30+
}
31+
}

zulip_bots/zulip_bots/bots/baremetrics/test_baremetrics.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def test_exception_when_api_key_is_invalid(self)-> None:
7878
bot_test_instance = BaremetricsHandler()
7979

8080
with self.mock_config_info({'api_key': 'TEST'}):
81-
with self.assertRaises(StubBotHandler.BotQuitException):
82-
bot_test_instance.initialize(StubBotHandler())
81+
with self.mock_http_conversation('invalid_api_key'):
82+
with self.assertRaises(StubBotHandler.BotQuitException):
83+
bot_test_instance.initialize(StubBotHandler())
8384

8485
def test_invalid_command(self) -> None:
8586
with self.mock_config_info({'api_key': 'TEST'}), \

0 commit comments

Comments
 (0)