diff options
Diffstat (limited to 'openstackclient/tests/unit/volume/v2')
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_consistency_group.py | 4 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_volume.py | 53 |
2 files changed, 52 insertions, 5 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py index 7ef4a08e..c5537ed8 100644 --- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py +++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py @@ -257,7 +257,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup): self.new_consistency_group.name, ] verifylist = [ - ('consistency_group_source', self.new_consistency_group.id), + ('source', self.new_consistency_group.id), ('description', self.new_consistency_group.description), ('name', self.new_consistency_group.name), ] @@ -285,7 +285,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup): self.new_consistency_group.name, ] verifylist = [ - ('consistency_group_snapshot', self.consistency_group_snapshot.id), + ('snapshot', self.consistency_group_snapshot.id), ('description', self.new_consistency_group.description), ('name', self.new_consistency_group.name), ] diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py index c930002f..0419acef 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume.py +++ b/openstackclient/tests/unit/volume/v2/test_volume.py @@ -435,7 +435,8 @@ class TestVolumeCreate(TestVolume): self.assertEqual(self.columns, columns) self.assertCountEqual(self.datalist, data) - def test_volume_create_with_bootable_and_readonly(self): + @mock.patch.object(utils, 'wait_for_status', return_value=True) + def test_volume_create_with_bootable_and_readonly(self, mock_wait): arglist = [ '--bootable', '--read-only', @@ -478,7 +479,8 @@ class TestVolumeCreate(TestVolume): self.volumes_mock.update_readonly_flag.assert_called_with( self.new_volume.id, True) - def test_volume_create_with_nonbootable_and_readwrite(self): + @mock.patch.object(utils, 'wait_for_status', return_value=True) + def test_volume_create_with_nonbootable_and_readwrite(self, mock_wait): arglist = [ '--non-bootable', '--read-write', @@ -522,8 +524,9 @@ class TestVolumeCreate(TestVolume): self.new_volume.id, False) @mock.patch.object(volume.LOG, 'error') + @mock.patch.object(utils, 'wait_for_status', return_value=True) def test_volume_create_with_bootable_and_readonly_fail( - self, mock_error): + self, mock_wait, mock_error): self.volumes_mock.set_bootable.side_effect = ( exceptions.CommandError()) @@ -574,6 +577,50 @@ class TestVolumeCreate(TestVolume): self.volumes_mock.update_readonly_flag.assert_called_with( self.new_volume.id, True) + @mock.patch.object(volume.LOG, 'error') + @mock.patch.object(utils, 'wait_for_status', return_value=False) + def test_volume_create_non_available_with_readonly( + self, mock_wait, mock_error, + ): + arglist = [ + '--non-bootable', + '--read-only', + '--size', str(self.new_volume.size), + self.new_volume.name, + ] + verifylist = [ + ('bootable', False), + ('non_bootable', True), + ('read_only', True), + ('read_write', False), + ('size', self.new_volume.size), + ('name', self.new_volume.name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + size=self.new_volume.size, + snapshot_id=None, + name=self.new_volume.name, + description=None, + volume_type=None, + availability_zone=None, + metadata=None, + imageRef=None, + source_volid=None, + consistencygroup_id=None, + scheduler_hints=None, + backup_id=None, + ) + + self.assertEqual(2, mock_error.call_count) + self.assertEqual(self.columns, columns) + self.assertCountEqual(self.datalist, data) + def test_volume_create_without_size(self): arglist = [ self.new_volume.name, |
