From 41d6ed0861d222858868375a7f0e3df86737a974 Mon Sep 17 00:00:00 2001 From: "jeremy.zhang" Date: Mon, 8 Jan 2018 17:21:33 +0800 Subject: [PATCH] Fix v2 volume unit tests This patch is mainly to fix the wrongly used fake client in v2 volume unit tests. Change-Id: If0d0aa7a95b7d58886cc77e8a377ac2f17985f18 --- cinderclient/tests/unit/v2/test_volumes.py | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/cinderclient/tests/unit/v2/test_volumes.py b/cinderclient/tests/unit/v2/test_volumes.py index 60549eae6..6e5fd2ff3 100644 --- a/cinderclient/tests/unit/v2/test_volumes.py +++ b/cinderclient/tests/unit/v2/test_volumes.py @@ -15,13 +15,11 @@ # License for the specific language governing permissions and limitations # under the License. -from cinderclient import api_versions from cinderclient.tests.unit import utils from cinderclient.tests.unit.v2 import fakes from cinderclient.v2.volumes import Volume cs = fakes.FakeClient() -cs3 = fakes.FakeClient(api_versions.APIVersion('3.15')) class VolumesTest(utils.TestCase): @@ -213,23 +211,23 @@ class VolumesTest(utils.TestCase): self._assert_request_id(vol) def test_migrate(self): - v = cs3.volumes.get('1234') + v = cs.volumes.get('1234') self._assert_request_id(v) - vol = cs3.volumes.migrate_volume(v, 'dest', False, False) - cs3.assert_called('POST', '/volumes/1234/action', - {'os-migrate_volume': {'host': 'dest', - 'force_host_copy': False, + vol = cs.volumes.migrate_volume(v, 'dest', False, False) + cs.assert_called('POST', '/volumes/1234/action', + {'os-migrate_volume': {'host': 'dest', + 'force_host_copy': False, 'lock_volume': False}}) self._assert_request_id(vol) def test_migrate_with_lock_volume(self): - v = cs3.volumes.get('1234') + v = cs.volumes.get('1234') self._assert_request_id(v) - vol = cs3.volumes.migrate_volume(v, 'dest', False, True) - cs3.assert_called('POST', '/volumes/1234/action', - {'os-migrate_volume': {'host': 'dest', - 'force_host_copy': False, - 'lock_volume': True}}) + vol = cs.volumes.migrate_volume(v, 'dest', False, True) + cs.assert_called('POST', '/volumes/1234/action', + {'os-migrate_volume': {'host': 'dest', + 'force_host_copy': False, + 'lock_volume': True}}) self._assert_request_id(vol) def test_metadata_update_all(self): @@ -262,19 +260,19 @@ class VolumesTest(utils.TestCase): self._assert_request_id(vol) def test_volume_manage(self): - vol = cs3.volumes.manage('host1', {'k': 'v'}) + vol = cs.volumes.manage('host1', {'k': 'v'}) expected = {'host': 'host1', 'name': None, 'availability_zone': None, 'description': None, 'metadata': None, 'ref': {'k': 'v'}, 'volume_type': None, 'bootable': False} - cs3.assert_called('POST', '/os-volume-manage', {'volume': expected}) + cs.assert_called('POST', '/os-volume-manage', {'volume': expected}) self._assert_request_id(vol) def test_volume_manage_bootable(self): - vol = cs3.volumes.manage('host1', {'k': 'v'}, bootable=True) + vol = cs.volumes.manage('host1', {'k': 'v'}, bootable=True) expected = {'host': 'host1', 'name': None, 'availability_zone': None, 'description': None, 'metadata': None, 'ref': {'k': 'v'}, 'volume_type': None, 'bootable': True} - cs3.assert_called('POST', '/os-volume-manage', {'volume': expected}) + cs.assert_called('POST', '/os-volume-manage', {'volume': expected}) self._assert_request_id(vol) def test_volume_list_manageable(self):