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:
Adrian Turjak 2018-03-22 16:31:35 +13:00
parent 23ed0aa481
commit 1b7e5c05d0
2 changed files with 4 additions and 4 deletions

View File

@ -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:

View File

@ -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,