def test_asend_returns_appropriate_sorna_response(mocker, req_params,
mock_sorna_aresp):
req = Request(**req_params)
methods = Request._allowed_methods
for method in methods:
req.method = method
mock_reqfunc = mocker.patch.object(
aiohttp.ClientSession, method.lower(),
new_callable=asynctest.CoroutineMock
)
mock_reqfunc.return_value, conf = mock_sorna_aresp
resp = await req.asend()
assert isinstance(resp, Response)
assert resp.status == conf['status']
assert resp.reason == conf['reason']
assert resp.content_type == conf['content_type']
body = await conf['read']()
assert resp.content_length == len(body)
assert resp.text() == body.decode()
assert resp.json() == json.loads(body.decode())
评论列表
文章目录