summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2017-12-12 10:57:24 +0000
committerStephen Finucane <sfinucan@redhat.com>2018-01-02 11:36:02 +0000
commit4dcbc30e317a25495bebc073bb9913d9fd9d43a2 (patch)
tree41182f8e2feacd9cdf47999ca55d35ed650f97db
parent319579b34f635ea8efad81b7f6011ca06bfd7eba (diff)
downloadpython-glanceclient-4dcbc30e317a25495bebc073bb9913d9fd9d43a2.tar.gz
Compare against 'RequestIdProxy.wrapped'
Due to the 'glanceclient.common.utils.add_req_id_to_object' decorator, an instance of 'glanceclient.common.utils.RequestIdProxy' is returned for most calls in glanceclient. If we wish to compare to None, we have to compare the contents of this wrapper and not the wrapper itself. Unit tests are updated to highlight this. Change-Id: I7dadf32d37ac2bda33a92c71d5882e9f23e38a82 Closes-Bug: #1736759
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py9
-rw-r--r--glanceclient/v2/shell.py2
2 files changed, 5 insertions, 6 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index 4ac8c17..d75613f 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -581,11 +581,10 @@ class ShellV2Test(testtools.TestCase):
args = self._make_args(
{'id': 'IMG-01', 'file': 'test', 'progress': True})
- with mock.patch.object(self.gc.images, 'data') as mocked_data:
- def _data():
- for c in 'abcedf':
- yield c
- mocked_data.return_value = utils.IterableWithLength(_data(), 5)
+ with mock.patch.object(self.gc.images, 'data') as mocked_data, \
+ mock.patch.object(utils, '_extract_request_id'):
+ mocked_data.return_value = utils.RequestIdProxy(
+ [c for c in 'abcdef'])
test_shell.do_image_download(self.gc, args)
mocked_data.assert_called_once_with('IMG-01')
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 131e826..c9f1fe1 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -353,7 +353,7 @@ def do_image_download(gc, args):
msg = "Unable to download image '%s'. (%s)" % (args.id, e)
utils.exit(msg)
- if body is None:
+ if body.wrapped is None:
msg = ('Image %s has no data.' % args.id)
utils.exit(msg)