summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit
diff options
context:
space:
mode:
authorMitsuhiro Tanino <mitsuhiro.tanino@hds.com>2016-04-19 15:41:46 -0400
committerMitsuhiro Tanino <mitsuhiro.tanino@hds.com>2016-06-02 17:10:27 -0400
commitdf63cd03d5733c7779a67bfbdbaa312b6224352c (patch)
treeca0af8b5e74c058d4335731d1a2a620d875ab6a7 /cinderclient/tests/unit
parent7d570540a4ade624a2305a010e485aec82e3edcf (diff)
downloadpython-cinderclient-df63cd03d5733c7779a67bfbdbaa312b6224352c.tar.gz
Support name option for volume restore
Volume restore API supports name option to specify volume name for new volume creation, but CLI doesn't support this option. This change simply add name option for backup-restore command. Change-Id: I22ccc303c86b958cb21862f718ef89f57234a027 Partial-Bug: #1539667
Diffstat (limited to 'cinderclient/tests/unit')
-rw-r--r--cinderclient/tests/unit/v2/test_shell.py18
-rw-r--r--cinderclient/tests/unit/v2/test_volume_backups.py10
2 files changed, 26 insertions, 2 deletions
diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py
index fc3490c..3c9b9fd 100644
--- a/cinderclient/tests/unit/v2/test_shell.py
+++ b/cinderclient/tests/unit/v2/test_shell.py
@@ -424,6 +424,17 @@ class ShellTest(utils.TestCase):
self.run_command('backup-restore 1234')
self.assert_called('POST', '/backups/1234/restore')
+ def test_restore_with_name(self):
+ self.run_command('backup-restore 1234 --name restore_vol')
+ expected = {'restore': {'volume_id': None, 'name': 'restore_vol'}}
+ self.assert_called('POST', '/backups/1234/restore',
+ body=expected)
+
+ def test_restore_with_name_error(self):
+ self.assertRaises(exceptions.CommandError, self.run_command,
+ 'backup-restore 1234 --volume fake_vol --name '
+ 'restore_vol')
+
@mock.patch('cinderclient.utils.print_dict')
@mock.patch('cinderclient.utils.find_volume')
def test_do_backup_restore(self,
@@ -431,9 +442,11 @@ class ShellTest(utils.TestCase):
mock_print_dict):
backup_id = '1234'
volume_id = '5678'
+ name = None
input = {
'backup': backup_id,
- 'volume': volume_id
+ 'volume': volume_id,
+ 'name': None
}
args = self._make_args(input)
@@ -445,7 +458,8 @@ class ShellTest(utils.TestCase):
test_shell.do_backup_restore(self.cs, args)
mocked_restore.assert_called_once_with(
input['backup'],
- volume_id)
+ volume_id,
+ name)
self.assertTrue(mock_print_dict.called)
def test_record_export(self):
diff --git a/cinderclient/tests/unit/v2/test_volume_backups.py b/cinderclient/tests/unit/v2/test_volume_backups.py
index ac8be24..c003164 100644
--- a/cinderclient/tests/unit/v2/test_volume_backups.py
+++ b/cinderclient/tests/unit/v2/test_volume_backups.py
@@ -100,6 +100,16 @@ class VolumeBackupsTest(utils.TestCase):
volume_backups_restore.VolumeBackupsRestore)
self._assert_request_id(info)
+ def test_restore_with_name(self):
+ backup_id = '76a17945-3c6f-435c-975b-b5685db10b62'
+ name = 'restore_vol'
+ info = cs.restores.restore(backup_id, name=name)
+ expected_body = {'restore': {'volume_id': None, 'name': name}}
+ cs.assert_called('POST', '/backups/%s/restore' % backup_id,
+ body=expected_body)
+ self.assertIsInstance(info,
+ volume_backups_restore.VolumeBackupsRestore)
+
def test_reset_state(self):
b = cs.backups.list()[0]
api = '/backups/76a17945-3c6f-435c-975b-b5685db10b62/action'