|
15 | 15 | from unittest import mock |
16 | 16 | from unittest.mock import call |
17 | 17 |
|
| 18 | +from cinderclient import api_versions |
18 | 19 | from osc_lib import exceptions |
19 | 20 | from osc_lib import utils |
20 | 21 |
|
@@ -172,6 +173,51 @@ def test_transfer_create_with_name(self): |
172 | 173 | self.assertEqual(self.columns, columns) |
173 | 174 | self.assertEqual(self.data, data) |
174 | 175 |
|
| 176 | + def test_transfer_create_with_no_snapshots(self): |
| 177 | + self.app.client_manager.volume.api_version = \ |
| 178 | + api_versions.APIVersion('3.55') |
| 179 | + |
| 180 | + arglist = [ |
| 181 | + '--no-snapshots', |
| 182 | + self.volume.id, |
| 183 | + ] |
| 184 | + verifylist = [ |
| 185 | + ('name', None), |
| 186 | + ('snapshots', False), |
| 187 | + ('volume', self.volume.id), |
| 188 | + ] |
| 189 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 190 | + |
| 191 | + columns, data = self.cmd.take_action(parsed_args) |
| 192 | + |
| 193 | + self.transfer_mock.create.assert_called_once_with( |
| 194 | + self.volume.id, None, no_snapshots=True) |
| 195 | + self.assertEqual(self.columns, columns) |
| 196 | + self.assertEqual(self.data, data) |
| 197 | + |
| 198 | + def test_transfer_create_pre_v355(self): |
| 199 | + self.app.client_manager.volume.api_version = \ |
| 200 | + api_versions.APIVersion('3.54') |
| 201 | + |
| 202 | + arglist = [ |
| 203 | + '--no-snapshots', |
| 204 | + self.volume.id, |
| 205 | + ] |
| 206 | + verifylist = [ |
| 207 | + ('name', None), |
| 208 | + ('snapshots', False), |
| 209 | + ('volume', self.volume.id), |
| 210 | + ] |
| 211 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 212 | + |
| 213 | + exc = self.assertRaises( |
| 214 | + exceptions.CommandError, |
| 215 | + self.cmd.take_action, |
| 216 | + parsed_args) |
| 217 | + self.assertIn( |
| 218 | + '--os-volume-api-version 3.55 or greater is required', |
| 219 | + str(exc)) |
| 220 | + |
175 | 221 |
|
176 | 222 | class TestTransferDelete(TestTransfer): |
177 | 223 |
|
|
0 commit comments