def test__raise_for_status(self, mock_resp):
"""
Verify that an exceptions gets raised for unexpected responses.
:param mock_resp: mocked httplib Response
"""
#
# ok_statuses should not raise
#
mock_resp.status = httplib.CREATED
self.up.resp = mock_resp
self.up.content = ''
try:
self.up._raise_for_status([httplib.OK, httplib.CREATED])
except Exception as exc:
self.fail('_raise_for_status unexpectedly threw {}'.format(exc))
#
# Anything else should raise.
#
mock_resp.status = httplib.ACCEPTED
self.assertRaises(
upapi.exceptions.UnexpectedAPIResponse,
self.up._raise_for_status,
[httplib.OK, httplib.CREATED])
评论列表
文章目录