diff options
author | Eric Harney <eharney@redhat.com> | 2019-03-27 11:16:15 -0400 |
---|---|---|
committer | Eric Harney <eharney@redhat.com> | 2019-04-03 11:34:40 -0400 |
commit | 274fa111696783e846561d12f670967ed01ebcbc (patch) | |
tree | 53dd829c8ff0206a8d39ec0a2c47f074d39fcd92 /cinderclient/tests/unit/test_shell.py | |
parent | 8804b7c978ebf056fa66e09b702355e44da71040 (diff) | |
download | python-cinderclient-274fa111696783e846561d12f670967ed01ebcbc.tar.gz |
Fix shell upload-to-image with no volume type
Upload-to-image would error after launching
the operation if the volume type is None.
Closes-Bug: #1821818
Change-Id: I015e0ddfa98d62f25334e2df5effaee72a3988ab
Diffstat (limited to 'cinderclient/tests/unit/test_shell.py')
-rw-r--r-- | cinderclient/tests/unit/test_shell.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index e611ace..a217378 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -502,3 +502,31 @@ class TestLoadVersionedActions(utils.TestCase): mock_add_arg.call_args_list) self.assertIn(mock.call('--foo', help="second foo"), mock_add_arg.call_args_list) + + +class ShellUtilsTest(utils.TestCase): + + @mock.patch.object(cinderclient.utils, 'print_dict') + def test_print_volume_image(self, mock_print_dict): + response = {'os-volume_upload_image': {'name': 'myimg1'}} + image_resp_tuple = (202, response) + cinderclient.shell_utils.print_volume_image(image_resp_tuple) + + response = {'os-volume_upload_image': + {'name': 'myimg2', + 'volume_type': None}} + image_resp_tuple = (202, response) + cinderclient.shell_utils.print_volume_image(image_resp_tuple) + + response = {'os-volume_upload_image': + {'name': 'myimg3', + 'volume_type': {'id': '1234', 'name': 'sometype'}}} + image_resp_tuple = (202, response) + cinderclient.shell_utils.print_volume_image(image_resp_tuple) + + mock_print_dict.assert_has_calls( + (mock.call({'name': 'myimg1'}), + mock.call({'name': 'myimg2', + 'volume_type': None}), + mock.call({'name': 'myimg3', + 'volume_type': 'sometype'}))) |