Fix response always being False
From requests.models.Response: Returns True if :attr:`status_code` is less than 400. We're using it wrong, so have changed it to "is not None" Change-Id: I617e55d67d93f1e07f5192ba94dcc0997ba9e12f
This commit is contained in:
parent
23ed0aa481
commit
1b7e5c05d0
|
@ -60,7 +60,7 @@ class HttpException(SDKException, _rex.HTTPError):
|
|||
# TODO(shade) Remove http_status parameter and the ability for response
|
||||
# to be None once we're not mocking Session everywhere.
|
||||
if not message:
|
||||
if response:
|
||||
if response is not None:
|
||||
message = "{name}: {code}".format(
|
||||
name=self.__class__.__name__,
|
||||
code=response.status_code)
|
||||
|
@ -72,7 +72,7 @@ class HttpException(SDKException, _rex.HTTPError):
|
|||
SDKException.__init__(self, message=message)
|
||||
_rex.HTTPError.__init__(self, message, response=response)
|
||||
|
||||
if response:
|
||||
if response is not None:
|
||||
self.request_id = response.headers.get('x-openstack-request-id')
|
||||
self.status_code = response.status_code
|
||||
else:
|
||||
|
|
|
@ -650,7 +650,7 @@ class TestImage(BaseTestImage):
|
|||
]
|
||||
mock_image_client.post.return_value = ret
|
||||
mock_image_client.put.side_effect = exc.OpenStackCloudHTTPError(
|
||||
"Some error", {})
|
||||
"Some error")
|
||||
self.assertRaises(
|
||||
exc.OpenStackCloudHTTPError,
|
||||
self._call_create_image,
|
||||
|
@ -724,7 +724,7 @@ class TestImage(BaseTestImage):
|
|||
]
|
||||
mock_image_client.post.return_value = ret
|
||||
mock_image_client.put.side_effect = exc.OpenStackCloudHTTPError(
|
||||
"Some error", {})
|
||||
"Some error")
|
||||
self.assertRaises(
|
||||
exc.OpenStackCloudHTTPError,
|
||||
self._call_create_image,
|
||||
|
|
Loading…
Reference in New Issue