Use status_code instead of status in requests
It fixes raising exception for response with not recognized
status code.
Co-Authored-By: Brian Haley <haleyb.dev@gmail.com>
Change-Id: I174ff62cb6599e4c7bdc86cb2d0786f9f2499b00
Related-Bug: 1790598
(cherry picked from commit 1685982a97
)
This commit is contained in:
parent
886782c177
commit
9f003cf497
|
@ -231,7 +231,8 @@ class MetadataProxyHandler(object):
|
|||
explanation = six.text_type(msg)
|
||||
return webob.exc.HTTPInternalServerError(explanation=explanation)
|
||||
else:
|
||||
raise Exception(_('Unexpected response code: %s') % resp.status)
|
||||
raise Exception(_('Unexpected response code: %s') %
|
||||
resp.status_code)
|
||||
|
||||
def _sign_instance_id(self, instance_id):
|
||||
secret = self.conf.metadata_proxy_shared_secret
|
||||
|
|
|
@ -340,6 +340,7 @@ class _TestMetadataProxyHandlerCacheMixin(object):
|
|||
req = mock.Mock(path_info='/the_path', query_string='', headers=hdrs,
|
||||
method=method, body=body)
|
||||
resp = mock.MagicMock(status_code=response_code)
|
||||
resp.status.__str__.side_effect = AttributeError
|
||||
resp.content = 'content'
|
||||
req.response = resp
|
||||
with mock.patch.object(self.handler, '_sign_instance_id') as sign:
|
||||
|
|
Loading…
Reference in New Issue