summaryrefslogtreecommitdiff
path: root/cinderclient/tests
diff options
context:
space:
mode:
authorIvan Kolodyazhny <e0ne@e0ne.info>2016-05-20 22:20:26 +0300
committerIvan Kolodyazhny <e0ne@e0ne.info>2016-05-20 22:55:55 +0300
commit9e19357e4beff1131492888b7f2766afb227a767 (patch)
treec9208e75ca0f704c2dfff1cf844ebc4824c1ea9c /cinderclient/tests
parent0cdcfb5988f57da80551b1a11fcd3d96d0baf1d8 (diff)
downloadpython-cinderclient-1.7.1.tar.gz
Fix upload_to_image method1.7.1
Commit Ie639179c5bbbaca4de62b42b368830afcfd8f7ac introduced 'visibility' and 'protected' params. These params should be used only with v3.1 microversion. Also these changes break current v2 users. This patch fixes these issues. Closes-Bug: #1584056 Change-Id: I0574631791c475bbefdb6e7d1647a20d0759df64
Diffstat (limited to 'cinderclient/tests')
-rw-r--r--cinderclient/tests/unit/utils.py5
-rw-r--r--cinderclient/tests/unit/v2/test_shell.py26
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py25
3 files changed, 32 insertions, 24 deletions
diff --git a/cinderclient/tests/unit/utils.py b/cinderclient/tests/unit/utils.py
index ddf8972..def38bd 100644
--- a/cinderclient/tests/unit/utils.py
+++ b/cinderclient/tests/unit/utils.py
@@ -44,6 +44,11 @@ class TestCase(testtools.TestCase):
self.assertTrue(hasattr(obj, 'request_ids'))
self.assertEqual(REQUEST_ID, obj.request_ids)
+ def assert_called_anytime(self, method, url, body=None,
+ partial_body=None):
+ return self.shell.cs.assert_called_anytime(method, url, body,
+ partial_body)
+
class FixturedTestCase(TestCase):
diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py
index d94c302..88c447f 100644
--- a/cinderclient/tests/unit/v2/test_shell.py
+++ b/cinderclient/tests/unit/v2/test_shell.py
@@ -71,11 +71,6 @@ class ShellTest(utils.TestCase):
return self.shell.cs.assert_called(method, url, body,
partial_body, **kwargs)
- def assert_called_anytime(self, method, url, body=None,
- partial_body=None):
- return self.shell.cs.assert_called_anytime(method, url, body,
- partial_body)
-
def test_list(self):
self.run_command('list')
# NOTE(jdg): we default to detail currently
@@ -359,9 +354,7 @@ class ShellTest(utils.TestCase):
expected = {'os-volume_upload_image': {'force': False,
'container_format': 'bare',
'disk_format': 'raw',
- 'image_name': 'test-image',
- 'protected': False,
- 'visibility': 'private'}}
+ 'image_name': 'test-image'}}
self.run_command('upload-to-image 1234 test-image')
self.assert_called_anytime('GET', '/volumes/1234')
self.assert_called_anytime('POST', '/volumes/1234/action',
@@ -371,27 +364,12 @@ class ShellTest(utils.TestCase):
expected = {'os-volume_upload_image': {'force': 'True',
'container_format': 'bare',
'disk_format': 'raw',
- 'image_name': 'test-image',
- 'protected': False,
- 'visibility': 'private'}}
+ 'image_name': 'test-image'}}
self.run_command('upload-to-image --force=True 1234 test-image')
self.assert_called_anytime('GET', '/volumes/1234')
self.assert_called_anytime('POST', '/volumes/1234/action',
body=expected)
- def test_upload_to_image_public_protected(self):
- expected = {'os-volume_upload_image': {'force': False,
- 'container_format': 'bare',
- 'disk_format': 'raw',
- 'image_name': 'test-image',
- 'protected': 'True',
- 'visibility': 'public'}}
- self.run_command('upload-to-image --visibility=public '
- '--protected=True 1234 test-image')
- self.assert_called_anytime('GET', '/volumes/1234')
- self.assert_called_anytime('POST', '/volumes/1234/action',
- body=expected)
-
def test_create_size_required_if_not_snapshot_or_clone(self):
self.assertRaises(SystemExit, self.run_command, 'create')
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index e18f647..35e205d 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -68,3 +68,28 @@ class ShellTest(utils.TestCase):
def test_list_availability_zone(self):
self.run_command('availability-zone-list')
self.assert_called('GET', '/os-availability-zone')
+
+ def test_upload_to_image(self):
+ expected = {'os-volume_upload_image': {'force': False,
+ 'container_format': 'bare',
+ 'disk_format': 'raw',
+ 'image_name': 'test-image',
+ 'protected': False,
+ 'visibility': 'private'}}
+ self.run_command('upload-to-image 1234 test-image')
+ self.assert_called_anytime('GET', '/volumes/1234')
+ self.assert_called_anytime('POST', '/volumes/1234/action',
+ body=expected)
+
+ def test_upload_to_image_public_protected(self):
+ expected = {'os-volume_upload_image': {'force': False,
+ 'container_format': 'bare',
+ 'disk_format': 'raw',
+ 'image_name': 'test-image',
+ 'protected': 'True',
+ 'visibility': 'public'}}
+ self.run_command('upload-to-image --visibility=public '
+ '--protected=True 1234 test-image')
+ self.assert_called_anytime('GET', '/volumes/1234')
+ self.assert_called_anytime('POST', '/volumes/1234/action',
+ body=expected)