|
12 | 12 | # under the License. |
13 | 13 |
|
14 | 14 | from unittest import mock |
15 | | -from unittest.mock import call |
16 | 15 |
|
17 | | -from cinderclient import api_versions |
18 | 16 | from osc_lib.cli import format_columns |
19 | 17 | from osc_lib import exceptions |
20 | 18 | from osc_lib import utils |
@@ -42,9 +40,6 @@ def setUp(self): |
42 | 40 | self.snapshots_mock = self.volume_client.volume_snapshots |
43 | 41 | self.snapshots_mock.reset_mock() |
44 | 42 |
|
45 | | - self.backups_mock = self.volume_client.backups |
46 | | - self.backups_mock.reset_mock() |
47 | | - |
48 | 43 | self.types_mock = self.volume_client.volume_types |
49 | 44 | self.types_mock.reset_mock() |
50 | 45 |
|
@@ -126,7 +121,6 @@ def test_volume_create_min_options(self): |
126 | 121 | source_volid=None, |
127 | 122 | consistencygroup_id=None, |
128 | 123 | scheduler_hints=None, |
129 | | - backup_id=None, |
130 | 124 | ) |
131 | 125 |
|
132 | 126 | self.assertEqual(self.columns, columns) |
@@ -178,7 +172,6 @@ def test_volume_create_options(self): |
178 | 172 | source_volid=None, |
179 | 173 | consistencygroup_id=consistency_group.id, |
180 | 174 | scheduler_hints={'k': 'v'}, |
181 | | - backup_id=None, |
182 | 175 | ) |
183 | 176 |
|
184 | 177 | self.assertEqual(self.columns, columns) |
@@ -218,7 +211,6 @@ def test_volume_create_properties(self): |
218 | 211 | source_volid=None, |
219 | 212 | consistencygroup_id=None, |
220 | 213 | scheduler_hints=None, |
221 | | - backup_id=None, |
222 | 214 | ) |
223 | 215 |
|
224 | 216 | self.assertEqual(self.columns, columns) |
@@ -259,7 +251,6 @@ def test_volume_create_image_id(self): |
259 | 251 | source_volid=None, |
260 | 252 | consistencygroup_id=None, |
261 | 253 | scheduler_hints=None, |
262 | | - backup_id=None, |
263 | 254 | ) |
264 | 255 |
|
265 | 256 | self.assertEqual(self.columns, columns) |
@@ -300,7 +291,6 @@ def test_volume_create_image_name(self): |
300 | 291 | source_volid=None, |
301 | 292 | consistencygroup_id=None, |
302 | 293 | scheduler_hints=None, |
303 | | - backup_id=None, |
304 | 294 | ) |
305 | 295 |
|
306 | 296 | self.assertEqual(self.columns, columns) |
@@ -339,74 +329,11 @@ def test_volume_create_with_snapshot(self): |
339 | 329 | source_volid=None, |
340 | 330 | consistencygroup_id=None, |
341 | 331 | scheduler_hints=None, |
342 | | - backup_id=None, |
343 | | - ) |
344 | | - |
345 | | - self.assertEqual(self.columns, columns) |
346 | | - self.assertCountEqual(self.datalist, data) |
347 | | - |
348 | | - def test_volume_create_with_backup(self): |
349 | | - backup = volume_fakes.create_one_backup() |
350 | | - self.new_volume.backup_id = backup.id |
351 | | - arglist = [ |
352 | | - '--backup', |
353 | | - self.new_volume.backup_id, |
354 | | - self.new_volume.name, |
355 | | - ] |
356 | | - verifylist = [ |
357 | | - ('backup', self.new_volume.backup_id), |
358 | | - ('name', self.new_volume.name), |
359 | | - ] |
360 | | - parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
361 | | - |
362 | | - self.backups_mock.get.return_value = backup |
363 | | - |
364 | | - self.volume_client.api_version = api_versions.APIVersion('3.47') |
365 | | - |
366 | | - # In base command class ShowOne in cliff, abstract method take_action() |
367 | | - # returns a two-part tuple with a tuple of column names and a tuple of |
368 | | - # data to be shown. |
369 | | - columns, data = self.cmd.take_action(parsed_args) |
370 | | - |
371 | | - self.volumes_mock.create.assert_called_once_with( |
372 | | - size=backup.size, |
373 | | - snapshot_id=None, |
374 | | - name=self.new_volume.name, |
375 | | - description=None, |
376 | | - volume_type=None, |
377 | | - availability_zone=None, |
378 | | - metadata=None, |
379 | | - imageRef=None, |
380 | | - source_volid=None, |
381 | | - consistencygroup_id=None, |
382 | | - scheduler_hints=None, |
383 | | - backup_id=backup.id, |
384 | 332 | ) |
385 | 333 |
|
386 | 334 | self.assertEqual(self.columns, columns) |
387 | 335 | self.assertCountEqual(self.datalist, data) |
388 | 336 |
|
389 | | - def test_volume_create_with_backup_pre_347(self): |
390 | | - backup = volume_fakes.create_one_backup() |
391 | | - self.new_volume.backup_id = backup.id |
392 | | - arglist = [ |
393 | | - '--backup', |
394 | | - self.new_volume.backup_id, |
395 | | - self.new_volume.name, |
396 | | - ] |
397 | | - verifylist = [ |
398 | | - ('backup', self.new_volume.backup_id), |
399 | | - ('name', self.new_volume.name), |
400 | | - ] |
401 | | - parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
402 | | - |
403 | | - self.backups_mock.get.return_value = backup |
404 | | - |
405 | | - exc = self.assertRaises( |
406 | | - exceptions.CommandError, self.cmd.take_action, parsed_args |
407 | | - ) |
408 | | - self.assertIn("--os-volume-api-version 3.47 or greater", str(exc)) |
409 | | - |
410 | 337 | def test_volume_create_with_source_volume(self): |
411 | 338 | source_vol = "source_vol" |
412 | 339 | arglist = [ |
@@ -439,7 +366,6 @@ def test_volume_create_with_source_volume(self): |
439 | 366 | source_volid=self.new_volume.id, |
440 | 367 | consistencygroup_id=None, |
441 | 368 | scheduler_hints=None, |
442 | | - backup_id=None, |
443 | 369 | ) |
444 | 370 |
|
445 | 371 | self.assertEqual(self.columns, columns) |
@@ -479,7 +405,6 @@ def test_volume_create_with_bootable_and_readonly(self, mock_wait): |
479 | 405 | source_volid=None, |
480 | 406 | consistencygroup_id=None, |
481 | 407 | scheduler_hints=None, |
482 | | - backup_id=None, |
483 | 408 | ) |
484 | 409 |
|
485 | 410 | self.assertEqual(self.columns, columns) |
@@ -525,7 +450,6 @@ def test_volume_create_with_nonbootable_and_readwrite(self, mock_wait): |
525 | 450 | source_volid=None, |
526 | 451 | consistencygroup_id=None, |
527 | 452 | scheduler_hints=None, |
528 | | - backup_id=None, |
529 | 453 | ) |
530 | 454 |
|
531 | 455 | self.assertEqual(self.columns, columns) |
@@ -580,7 +504,6 @@ def test_volume_create_with_bootable_and_readonly_fail( |
580 | 504 | source_volid=None, |
581 | 505 | consistencygroup_id=None, |
582 | 506 | scheduler_hints=None, |
583 | | - backup_id=None, |
584 | 507 | ) |
585 | 508 |
|
586 | 509 | self.assertEqual(2, mock_error.call_count) |
@@ -632,7 +555,6 @@ def test_volume_create_non_available_with_readonly( |
632 | 555 | source_volid=None, |
633 | 556 | consistencygroup_id=None, |
634 | 557 | scheduler_hints=None, |
635 | | - backup_id=None, |
636 | 558 | ) |
637 | 559 |
|
638 | 560 | self.assertEqual(2, mock_error.call_count) |
@@ -742,7 +664,6 @@ def test_volume_create_hints(self): |
742 | 664 | 'local_to_instance': 'v6', |
743 | 665 | 'different_host': ['v5', 'v7'], |
744 | 666 | }, |
745 | | - backup_id=None, |
746 | 667 | ) |
747 | 668 |
|
748 | 669 | self.assertEqual(self.columns, columns) |
@@ -789,7 +710,7 @@ def test_volume_delete_multi_volumes(self): |
789 | 710 |
|
790 | 711 | result = self.cmd.take_action(parsed_args) |
791 | 712 |
|
792 | | - calls = [call(v.id, cascade=False) for v in volumes] |
| 713 | + calls = [mock.call(v.id, cascade=False) for v in volumes] |
793 | 714 | self.volumes_mock.delete.assert_has_calls(calls) |
794 | 715 | self.assertIsNone(result) |
795 | 716 |
|
@@ -1721,11 +1642,23 @@ def test_volume_show(self): |
1721 | 1642 | self.volumes_mock.get.assert_called_with(self._volume.id) |
1722 | 1643 |
|
1723 | 1644 | self.assertEqual( |
1724 | | - volume_fakes.get_volume_columns(self._volume), |
| 1645 | + tuple(sorted(self._volume.keys())), |
1725 | 1646 | columns, |
1726 | 1647 | ) |
1727 | | - self.assertCountEqual( |
1728 | | - volume_fakes.get_volume_data(self._volume), |
| 1648 | + self.assertTupleEqual( |
| 1649 | + ( |
| 1650 | + self._volume.attachments, |
| 1651 | + self._volume.availability_zone, |
| 1652 | + self._volume.bootable, |
| 1653 | + self._volume.description, |
| 1654 | + self._volume.id, |
| 1655 | + self._volume.name, |
| 1656 | + format_columns.DictColumn(self._volume.metadata), |
| 1657 | + self._volume.size, |
| 1658 | + self._volume.snapshot_id, |
| 1659 | + self._volume.status, |
| 1660 | + self._volume.volume_type, |
| 1661 | + ), |
1729 | 1662 | data, |
1730 | 1663 | ) |
1731 | 1664 |
|
|
0 commit comments