Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res = expect(c, 'GET', '/payments')
res.status_code = 400
with pytest.raises(errors.BadRequestError):
c.get('/payments')
res = expect(c, 'GET', '/payments')
res.status_code = 401
with pytest.raises(errors.AuthenticationError):
c.get('/payments')
res = expect(c, 'GET', '/payments')
res.status_code = 404
with pytest.raises(errors.NotFoundError):
c.get('/payments')
res = expect(c, 'GET', '/payments')
res.status_code = 500
with pytest.raises(errors.Error):
c.get('/payments')
def _handle_request_error(self, error):
if isinstance(error, requests.HTTPError):
status = error.response.status_code
if status == 400:
raise errors.BadRequestError(error)
elif status == 401:
raise errors.AuthenticationError(error)
elif status == 404:
raise errors.NotFoundError(error)
raise errors.Error(error)