-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathtest_response.py
46 lines (41 loc) · 1.35 KB
/
test_response.py
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
from arango.response import Response
def test_response(conn):
response = Response(
method="get",
url="test_url",
headers={"foo": "bar"},
status_text="baz",
status_code=200,
raw_body="true",
)
conn.prep_response(response)
assert response.method == "get"
assert response.url == "test_url"
assert response.headers == {"foo": "bar"}
assert response.status_code == 200
assert response.status_text == "baz"
assert response.raw_body == "true"
assert response.body is True
assert response.error_code is None
assert response.error_message is None
assert response.is_success is True
test_body = '{"errorNum": 1, "errorMessage": "qux"}'
response = Response(
method="get",
url="test_url",
headers={"foo": "bar"},
status_text="baz",
status_code=200,
raw_body=test_body,
)
conn.prep_response(response)
assert response.method == "get"
assert response.url == "test_url"
assert response.headers == {"foo": "bar"}
assert response.status_code == 200
assert response.status_text == "baz"
assert response.raw_body == test_body
assert response.body == {"errorMessage": "qux", "errorNum": 1}
assert response.error_code == 1
assert response.error_message == "qux"
assert response.is_success is False