Merge "Ensure that failing responses are logged"
This commit is contained in:
@@ -201,7 +201,7 @@ class Session(object):
|
|||||||
if not logger.isEnabledFor(logging.DEBUG):
|
if not logger.isEnabledFor(logging.DEBUG):
|
||||||
return
|
return
|
||||||
|
|
||||||
if response:
|
if response is not None:
|
||||||
if not status_code:
|
if not status_code:
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
if not headers:
|
if not headers:
|
||||||
|
@@ -174,6 +174,18 @@ class SessionTests(utils.TestCase):
|
|||||||
self.assertEqual(v, resp.headers[k])
|
self.assertEqual(v, resp.headers[k])
|
||||||
self.assertNotIn(v, self.logger.output)
|
self.assertNotIn(v, self.logger.output)
|
||||||
|
|
||||||
|
def test_logs_failed_output(self):
|
||||||
|
"""Test that output is logged even for failed requests"""
|
||||||
|
|
||||||
|
session = client_session.Session()
|
||||||
|
body = uuid.uuid4().hex
|
||||||
|
|
||||||
|
self.stub_url('GET', text=body, status_code=400)
|
||||||
|
resp = session.get(self.TEST_URL, raise_exc=False)
|
||||||
|
|
||||||
|
self.assertEqual(resp.status_code, 400)
|
||||||
|
self.assertIn(body, self.logger.output)
|
||||||
|
|
||||||
def test_logging_cacerts(self):
|
def test_logging_cacerts(self):
|
||||||
path_to_certs = '/path/to/certs'
|
path_to_certs = '/path/to/certs'
|
||||||
session = client_session.Session(verify=path_to_certs)
|
session = client_session.Session(verify=path_to_certs)
|
||||||
|
Reference in New Issue
Block a user