blob: 948f247f6bfd697020795fd360bbdddb4722f484 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
from textwrap import dedent
from wee_slack import SlackRequest
def test_http_check_ratelimited_supports_multiple_headers(realish_eventrouter):
response = (
dedent(
"""
HTTP/1.1 200 Connection established
HTTP/2 200
content-type: application/json; charset=utf-8
{"ok": true}
"""
)
.strip()
.replace("\n", "\r\n")
)
request_metadata = SlackRequest(None, "", token="xoxp-1")
body, error = realish_eventrouter.http_check_ratelimited(request_metadata, response)
assert body == '{"ok": true}'
assert error == ""
def test_http_check_ratelimited_return_error_when_ratelimited(realish_eventrouter):
response = (
dedent(
"""
HTTP/2 429
content-type: application/json; charset=utf-8
retry-after: 10
{"ok": false, "error": "ratelimited"}
"""
)
.strip()
.replace("\n", "\r\n")
)
request_metadata = SlackRequest(None, "", token="xoxp-1")
body, error = realish_eventrouter.http_check_ratelimited(request_metadata, response)
assert body == ""
assert error == "ratelimited"
|