tests: Use consistent shortcut to fake volume client

This removes the need for a number of base test case subclasses. We use
'volume_client' rather than 'client' to avoid conflicts with clients for
other services.

Change-Id: I28d78f32142bb3a3fde0ba1780c504adc31cc77c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-09-06 11:02:11 +01:00
parent 02cc064258
commit 4cabf6f7a2
41 changed files with 304 additions and 522 deletions

View File

@ -87,8 +87,8 @@ class TestAvailabilityZone(network_fakes.FakeClientMixin, utils.TestCommand):
self.compute_client.availability_zones = mock.Mock()
self.app.client_manager.sdk_connection.volume = mock.Mock()
self.volume_client = self.app.client_manager.sdk_connection.volume
self.volume_client.availability_zones = mock.Mock()
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
self.volume_sdk_client.availability_zones = mock.Mock()
class TestAvailabilityZoneList(TestAvailabilityZone):
@ -110,7 +110,9 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
super().setUp()
self.compute_client.availability_zones.return_value = self.compute_azs
self.volume_client.availability_zones.return_value = self.volume_azs
self.volume_sdk_client.availability_zones.return_value = (
self.volume_azs
)
self.network_client.availability_zones.return_value = self.network_azs
# Get the command object to test
@ -127,7 +129,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
columns, data = self.cmd.take_action(parsed_args)
self.compute_client.availability_zones.assert_called_with(details=True)
self.volume_client.availability_zones.assert_called_with()
self.volume_sdk_client.availability_zones.assert_called_with()
self.network_client.availability_zones.assert_called_with()
self.assertEqual(self.short_columnslist, columns)
@ -155,7 +157,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
columns, data = self.cmd.take_action(parsed_args)
self.compute_client.availability_zones.assert_called_with(details=True)
self.volume_client.availability_zones.assert_called_with()
self.volume_sdk_client.availability_zones.assert_called_with()
self.network_client.availability_zones.assert_called_with()
self.assertEqual(self.long_columnslist, columns)
@ -189,7 +191,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
columns, data = self.cmd.take_action(parsed_args)
self.compute_client.availability_zones.assert_called_with(details=True)
self.volume_client.availability_zones.assert_not_called()
self.volume_sdk_client.availability_zones.assert_not_called()
self.network_client.availability_zones.assert_not_called()
self.assertEqual(self.short_columnslist, columns)
@ -213,7 +215,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
columns, data = self.cmd.take_action(parsed_args)
self.compute_client.availability_zones.assert_not_called()
self.volume_client.availability_zones.assert_called_with()
self.volume_sdk_client.availability_zones.assert_called_with()
self.network_client.availability_zones.assert_not_called()
self.assertEqual(self.short_columnslist, columns)
@ -237,7 +239,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
columns, data = self.cmd.take_action(parsed_args)
self.compute_client.availability_zones.assert_not_called()
self.volume_client.availability_zones.assert_not_called()
self.volume_sdk_client.availability_zones.assert_not_called()
self.network_client.availability_zones.assert_called_with()
self.assertEqual(self.short_columnslist, columns)

View File

@ -74,10 +74,9 @@ class TestVolumeLimits(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.app.client_manager.compute_endpoint_enabled = False
self.volume = self.app.client_manager.volume
self.fake_limits = volume_fakes.FakeLimits()
self.volume.limits.get.return_value = self.fake_limits
self.volume_client.limits.get.return_value = self.fake_limits
def test_volume_show_absolute(self):
arglist = ['--absolute']

View File

@ -55,11 +55,9 @@ class TestQuota(compute_fakes.TestComputev2):
)
self.compute_quotas_class_mock.reset_mock()
self.volume_quotas_mock = self.app.client_manager.volume.quotas
self.volume_quotas_mock = self.volume_client.quotas
self.volume_quotas_mock.reset_mock()
self.volume_quotas_class_mock = (
self.app.client_manager.volume.quota_classes
)
self.volume_quotas_class_mock = self.volume_client.quota_classes
self.volume_quotas_class_mock.reset_mock()
self.app.client_manager.auth_ref = mock.Mock()
@ -180,8 +178,7 @@ class TestQuotaList(TestQuota):
volume_fakes.create_one_default_vol_quota(),
volume_fakes.create_one_default_vol_quota(),
]
self.volume = self.app.client_manager.volume
self.volume.quotas.defaults = mock.Mock(
self.volume_client.quotas.defaults = mock.Mock(
side_effect=self.volume_default_quotas,
)
@ -288,7 +285,7 @@ class TestQuotaList(TestQuota):
detailed_quota
)
self.volume.quotas.get = mock.Mock(return_value=detailed_quota)
self.volume_client.quotas.get = mock.Mock(return_value=detailed_quota)
arglist = [
'--detail',
@ -541,7 +538,7 @@ class TestQuotaList(TestQuota):
def test_quota_list_volume(self):
# Two projects with non-default quotas
self.volume.quotas.get = mock.Mock(
self.volume_client.quotas.get = mock.Mock(
side_effect=self.volume_quotas,
)
@ -562,7 +559,7 @@ class TestQuotaList(TestQuota):
def test_quota_list_volume_default(self):
# Two projects with non-default quotas
self.volume.quotas.get = mock.Mock(
self.volume_client.quotas.get = mock.Mock(
side_effect=[
self.volume_quotas[0],
volume_fakes.create_one_default_vol_quota(),
@ -586,7 +583,7 @@ class TestQuotaList(TestQuota):
def test_quota_list_volume_no_project(self):
# Two projects with non-default quotas
self.volume.quotas.get = mock.Mock(
self.volume_client.quotas.get = mock.Mock(
side_effect=[
self.volume_quotas[0],
volume_fakes.create_one_default_vol_quota(),
@ -610,7 +607,7 @@ class TestQuotaList(TestQuota):
def test_quota_list_volume_by_project(self):
# Two projects with non-default quotas
self.volume.quotas.get = mock.Mock(
self.volume_client.quotas.get = mock.Mock(
side_effect=self.volume_quotas,
)

View File

@ -175,6 +175,7 @@ class TestComputev2(
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
)
self.volume_client = self.app.client_manager.volume
def create_one_aggregate(attrs=None):

View File

@ -92,14 +92,14 @@ class TestServer(compute_fakes.TestComputev2):
self.flavors_mock.reset_mock()
# Get a shortcut to the volume client VolumeManager Mock
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.app.client_manager.sdk_connection.volume = mock.Mock()
self.sdk_volume_client = self.app.client_manager.sdk_connection.volume
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
# Get a shortcut to the volume client VolumeManager Mock
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
# Set object attributes to be tested. Could be overwritten in subclass.
@ -162,7 +162,7 @@ class TestServer(compute_fakes.TestComputev2):
volumes = volume_fakes.create_sdk_volumes(count=count)
# This is the return value for volume_client.find_volume()
self.sdk_volume_client.find_volume.side_effect = volumes
self.volume_sdk_client.find_volume.side_effect = volumes
return volumes

View File

@ -29,7 +29,7 @@ class TestServerVolume(compute_fakes.TestComputev2):
self.app.client_manager.sdk_connection.compute = mock.Mock()
self.app.client_manager.sdk_connection.volume = mock.Mock()
self.compute_client = self.app.client_manager.sdk_connection.compute
self.volume_client = self.app.client_manager.sdk_connection.volume
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
class TestServerVolumeList(TestServerVolume):
@ -243,7 +243,7 @@ class TestServerVolumeUpdate(TestServerVolume):
self.compute_client.find_server.return_value = self.server
self.volume = volume_fakes.create_one_sdk_volume()
self.volume_client.find_volume.return_value = self.volume
self.volume_sdk_client.find_volume.return_value = self.volume
# Get the command object to test
self.cmd = server_volume.UpdateServerVolume(self.app, None)

View File

@ -39,6 +39,7 @@ class TestImagev1(FakeClientMixin, utils.TestCommand):
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
)
self.volume_client = self.app.client_manager.volume
def create_one_image(attrs=None):

View File

@ -593,7 +593,7 @@ class TestImageSet(image_fakes.TestImagev1):
def test_image_update_volume(self):
# Set up VolumeManager Mock
volumes_mock = self.app.client_manager.volume.volumes
volumes_mock = self.volume_client.volumes
volumes_mock.reset_mock()
volumes_mock.get.return_value = fakes.FakeResource(
None,

View File

@ -37,7 +37,7 @@ class TestImage(image_fakes.TestImagev2, volume_fakes.TestVolume):
self.project_mock.reset_mock()
self.domain_mock = self.app.client_manager.identity.domains
self.domain_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
fake_body = {
'os-volume_upload_image': {'volume_type': {'name': 'fake_type'}}
}
@ -369,9 +369,7 @@ class TestImageCreate(TestImage):
@mock.patch('osc_lib.utils.find_resource')
@mock.patch('openstackclient.image.v2.image.get_data_from_stdin')
def test_image_create_from_volume_v31(self, mock_get_data_f, mock_get_vol):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.1'
)
self.volume_client.api_version = api_versions.APIVersion('3.1')
fake_vol_id = 'fake-volume-id'
mock_get_data_f.return_value = None

View File

@ -61,6 +61,7 @@ class TestVolumev1(utils.TestCommand):
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
)
self.volume_client = self.app.client_manager.volume
self.app.client_manager.identity = identity_fakes.FakeIdentityv2Client(
endpoint=fakes.AUTH_URL,

View File

@ -29,10 +29,10 @@ class TestQos(volume_fakes.TestVolumev1):
def setUp(self):
super().setUp()
self.qos_mock = self.app.client_manager.volume.qos_specs
self.qos_mock = self.volume_client.qos_specs
self.qos_mock.reset_mock()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock = self.volume_client.volume_types
self.types_mock.reset_mock()

View File

@ -23,7 +23,7 @@ class TestService(volume_fakes.TestVolumev1):
super().setUp()
# Get a shortcut to the ServiceManager Mock
self.service_mock = self.app.client_manager.volume.services
self.service_mock = self.volume_client.services
self.service_mock.reset_mock()

View File

@ -27,11 +27,11 @@ class TestTransfer(volume_fakes.TestVolumev1):
super().setUp()
# Get a shortcut to the TransferManager Mock
self.transfer_mock = self.app.client_manager.volume.transfers
self.transfer_mock = self.volume_client.transfers
self.transfer_mock.reset_mock()
# Get a shortcut to the VolumeManager Mock
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()

View File

@ -28,12 +28,10 @@ class TestType(volume_fakes.TestVolumev1):
def setUp(self):
super().setUp()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock = self.volume_client.volume_types
self.types_mock.reset_mock()
self.encryption_types_mock = (
self.app.client_manager.volume.volume_encryption_types
)
self.encryption_types_mock = self.volume_client.volume_encryption_types
self.encryption_types_mock.reset_mock()

View File

@ -33,7 +33,7 @@ class TestVolume(volume_fakes.TestVolumev1):
super().setUp()
# Get a shortcut to the VolumeManager Mock
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
# Get a shortcut to the TenantManager Mock

View File

@ -26,13 +26,13 @@ class TestBackup(volume_fakes.TestVolumev1):
def setUp(self):
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock = self.volume_client.backups
self.backups_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
self.restores_mock = self.app.client_manager.volume.restores
self.restores_mock = self.volume_client.restores
self.restores_mock.reset_mock()

View File

@ -17,9 +17,11 @@ import random
from unittest import mock
import uuid
# FIXME(stephenfin): We are using v3 resource versions despite being v2 fakes
from cinderclient import api_versions
from openstack.block_storage.v2 import _proxy as block_storage_v2_proxy
from openstack.block_storage.v3 import backup as _backup
from openstack.block_storage.v3 import volume
from openstack.block_storage.v3 import volume as _volume
from openstack.image.v2 import _proxy as image_v2_proxy
from osc_lib.cli import format_columns
@ -94,6 +96,14 @@ class TestVolume(utils.TestCommand):
self.app.client_manager.volume = FakeVolumeClient(
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
)
self.volume_client = self.app.client_manager.volume
# TODO(stephenfin): Rename to 'volume_client' once all commands are
# migrated to SDK
self.app.client_manager.sdk_connection.volume = mock.Mock(
spec=block_storage_v2_proxy.Proxy,
)
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
@ -413,7 +423,7 @@ def create_one_sdk_volume(attrs=None):
# Overwrite default attributes if there are some attributes set
volume_info.update(attrs)
return volume.Volume(**volume_info)
return _volume.Volume(**volume_info)
def create_sdk_volumes(attrs=None, count=2):

View File

@ -20,7 +20,7 @@ class TestBackupRecord(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock = self.volume_client.backups
self.backups_mock.reset_mock()

View File

@ -28,18 +28,16 @@ class TestConsistencyGroup(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the TransferManager Mock
self.consistencygroups_mock = (
self.app.client_manager.volume.consistencygroups
)
self.consistencygroups_mock = self.volume_client.consistencygroups
self.consistencygroups_mock.reset_mock()
self.cgsnapshots_mock = self.app.client_manager.volume.cgsnapshots
self.cgsnapshots_mock = self.volume_client.cgsnapshots
self.cgsnapshots_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock = self.volume_client.volume_types
self.types_mock.reset_mock()

View File

@ -23,11 +23,9 @@ class TestConsistencyGroupSnapshot(volume_fakes.TestVolume):
super(TestConsistencyGroupSnapshot, self).setUp()
# Get a shortcut to the TransferManager Mock
self.cgsnapshots_mock = self.app.client_manager.volume.cgsnapshots
self.cgsnapshots_mock = self.volume_client.cgsnapshots
self.cgsnapshots_mock.reset_mock()
self.consistencygroups_mock = (
self.app.client_manager.volume.consistencygroups
)
self.consistencygroups_mock = self.volume_client.consistencygroups
self.consistencygroups_mock.reset_mock()

View File

@ -29,10 +29,10 @@ class TestQos(volume_fakes.TestVolume):
def setUp(self):
super(TestQos, self).setUp()
self.qos_mock = self.app.client_manager.volume.qos_specs
self.qos_mock = self.volume_client.qos_specs
self.qos_mock.reset_mock()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock = self.volume_client.volume_types
self.types_mock.reset_mock()

View File

@ -23,7 +23,7 @@ class TestService(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the ServiceManager Mock
self.service_mock = self.app.client_manager.volume.services
self.service_mock = self.volume_client.services
self.service_mock.reset_mock()

View File

@ -32,7 +32,7 @@ class TestVolume(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.projects_mock = self.app.client_manager.identity.projects
@ -41,18 +41,16 @@ class TestVolume(volume_fakes.TestVolume):
self.users_mock = self.app.client_manager.identity.users
self.users_mock.reset_mock()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock = self.volume_client.backups
self.backups_mock.reset_mock()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock = self.volume_client.volume_types
self.types_mock.reset_mock()
self.consistencygroups_mock = (
self.app.client_manager.volume.consistencygroups
)
self.consistencygroups_mock = self.volume_client.consistencygroups
self.consistencygroups_mock.reset_mock()
def setup_volumes_mock(self, count):
@ -365,9 +363,7 @@ class TestVolumeCreate(TestVolume):
self.backups_mock.get.return_value = backup
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.47'
)
self.volume_client.api_version = api_versions.APIVersion('3.47')
# In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of

View File

@ -26,7 +26,7 @@ class TestShowVolumeCapability(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the capability Mock
self.capability_mock = self.app.client_manager.volume.capabilities
self.capability_mock = self.volume_client.capabilities
self.capability_mock.get.return_value = self.capability
# Get the command object to test
@ -82,7 +82,7 @@ class TestListVolumePool(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.pool_mock = self.app.client_manager.volume.pools
self.pool_mock = self.volume_client.pools
self.pool_mock.list.return_value = [self.pools]
# Get the command object to test

View File

@ -27,13 +27,13 @@ class TestBackupLegacy(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock = self.volume_client.backups
self.backups_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
self.restores_mock = self.app.client_manager.volume.restores
self.restores_mock = self.volume_client.restores
self.restores_mock.reset_mock()
@ -42,7 +42,7 @@ class TestBackup(volume_fakes.TestVolume):
super().setUp()
self.app.client_manager.sdk_connection.volume = mock.Mock()
self.sdk_client = self.app.client_manager.sdk_connection.volume
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
patcher = mock.patch.object(
sdk_utils, 'supports_microversion', return_value=True
)
@ -82,9 +82,9 @@ class TestBackupCreate(TestBackup):
def setUp(self):
super().setUp()
self.sdk_client.find_volume.return_value = self.volume
self.sdk_client.find_snapshot.return_value = self.snapshot
self.sdk_client.create_backup.return_value = self.new_backup
self.volume_sdk_client.find_volume.return_value = self.volume
self.volume_sdk_client.find_snapshot.return_value = self.snapshot
self.volume_sdk_client.create_backup.return_value = self.new_backup
# Get the command object to test
self.cmd = volume_backup.CreateVolumeBackup(self.app, None)
@ -116,7 +116,7 @@ class TestBackupCreate(TestBackup):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.create_backup.assert_called_with(
self.volume_sdk_client.create_backup.assert_called_with(
volume_id=self.new_backup.volume_id,
container=self.new_backup.container,
name=self.new_backup.name,
@ -146,7 +146,7 @@ class TestBackupCreate(TestBackup):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.create_backup.assert_called_with(
self.volume_sdk_client.create_backup.assert_called_with(
volume_id=self.new_backup.volume_id,
container=None,
name=None,
@ -195,7 +195,7 @@ class TestBackupCreate(TestBackup):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.create_backup.assert_called_with(
self.volume_sdk_client.create_backup.assert_called_with(
volume_id=self.new_backup.volume_id,
container=None,
name=None,
@ -243,7 +243,7 @@ class TestBackupCreate(TestBackup):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.create_backup.assert_called_with(
self.volume_sdk_client.create_backup.assert_called_with(
volume_id=self.new_backup.volume_id,
container=self.new_backup.container,
name=None,
@ -261,8 +261,10 @@ class TestBackupDelete(TestBackup):
def setUp(self):
super().setUp()
self.sdk_client.find_backup = volume_fakes.get_backups(self.backups)
self.sdk_client.delete_backup.return_value = None
self.volume_sdk_client.find_backup = volume_fakes.get_backups(
self.backups
)
self.volume_sdk_client.delete_backup.return_value = None
# Get the command object to mock
self.cmd = volume_backup.DeleteVolumeBackup(self.app, None)
@ -274,7 +276,7 @@ class TestBackupDelete(TestBackup):
result = self.cmd.take_action(parsed_args)
self.sdk_client.delete_backup.assert_called_with(
self.volume_sdk_client.delete_backup.assert_called_with(
self.backups[0].id, ignore_missing=False, force=False
)
self.assertIsNone(result)
@ -289,7 +291,7 @@ class TestBackupDelete(TestBackup):
result = self.cmd.take_action(parsed_args)
self.sdk_client.delete_backup.assert_called_with(
self.volume_sdk_client.delete_backup.assert_called_with(
self.backups[0].id, ignore_missing=False, force=True
)
self.assertIsNone(result)
@ -308,7 +310,7 @@ class TestBackupDelete(TestBackup):
calls = []
for b in self.backups:
calls.append(call(b.id, ignore_missing=False, force=False))
self.sdk_client.delete_backup.assert_has_calls(calls)
self.volume_sdk_client.delete_backup.assert_has_calls(calls)
self.assertIsNone(result)
def test_delete_multiple_backups_with_exception(self):
@ -324,7 +326,7 @@ class TestBackupDelete(TestBackup):
find_mock_result = [self.backups[0], exceptions.CommandError]
with mock.patch.object(
self.sdk_client, 'find_backup', side_effect=find_mock_result
self.volume_sdk_client, 'find_backup', side_effect=find_mock_result
) as find_mock:
try:
self.cmd.take_action(parsed_args)
@ -336,7 +338,7 @@ class TestBackupDelete(TestBackup):
find_mock.assert_any_call('unexist_backup', ignore_missing=False)
self.assertEqual(2, find_mock.call_count)
self.sdk_client.delete_backup.assert_called_once_with(
self.volume_sdk_client.delete_backup.assert_called_once_with(
self.backups[0].id,
ignore_missing=False,
force=False,
@ -394,10 +396,10 @@ class TestBackupList(TestBackup):
def setUp(self):
super().setUp()
self.sdk_client.volumes.return_value = [self.volume]
self.sdk_client.backups.return_value = self.backups
self.sdk_client.find_volume.return_value = self.volume
self.sdk_client.find_backup.return_value = self.backups[0]
self.volume_sdk_client.volumes.return_value = [self.volume]
self.volume_sdk_client.backups.return_value = self.backups
self.volume_sdk_client.find_volume.return_value = self.volume
self.volume_sdk_client.find_backup.return_value = self.backups[0]
# Get the command to test
self.cmd = volume_backup.ListVolumeBackup(self.app, None)
@ -417,9 +419,9 @@ class TestBackupList(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.find_volume.assert_not_called()
self.sdk_client.find_backup.assert_not_called()
self.sdk_client.backups.assert_called_with(
self.volume_sdk_client.find_volume.assert_not_called()
self.volume_sdk_client.find_backup.assert_not_called()
self.volume_sdk_client.backups.assert_called_with(
name=None,
status=None,
volume_id=None,
@ -458,13 +460,13 @@ class TestBackupList(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.find_volume.assert_called_once_with(
self.volume_sdk_client.find_volume.assert_called_once_with(
self.volume.id, ignore_missing=False
)
self.sdk_client.find_backup.assert_called_once_with(
self.volume_sdk_client.find_backup.assert_called_once_with(
self.backups[0].id, ignore_missing=False
)
self.sdk_client.backups.assert_called_with(
self.volume_sdk_client.backups.assert_called_with(
name=self.backups[0].name,
status="error",
volume_id=self.volume.id,
@ -485,9 +487,9 @@ class TestBackupRestore(TestBackup):
def setUp(self):
super().setUp()
self.sdk_client.find_backup.return_value = self.backup
self.sdk_client.find_volume.return_value = self.volume
self.sdk_client.restore_backup.return_value = (
self.volume_sdk_client.find_backup.return_value = self.backup
self.volume_sdk_client.find_volume.return_value = self.volume
self.volume_sdk_client.restore_backup.return_value = (
volume_fakes.create_one_volume(
{'id': self.volume['id']},
)
@ -497,8 +499,9 @@ class TestBackupRestore(TestBackup):
self.cmd = volume_backup.RestoreVolumeBackup(self.app, None)
def test_backup_restore(self):
self.sdk_client.find_volume.side_effect = exceptions.CommandError()
# self.sdk_client.side_effect = exceptions.CommandError()
self.volume_sdk_client.find_volume.side_effect = (
exceptions.CommandError()
)
arglist = [self.backup.id]
verifylist = [
("backup", self.backup.id),
@ -507,7 +510,7 @@ class TestBackupRestore(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.sdk_client.restore_backup.assert_called_with(
self.volume_sdk_client.restore_backup.assert_called_with(
self.backup.id,
volume_id=None,
name=None,
@ -515,8 +518,9 @@ class TestBackupRestore(TestBackup):
self.assertIsNotNone(result)
def test_backup_restore_with_volume(self):
self.sdk_client.find_volume.side_effect = exceptions.CommandError()
# self.volumes_mock.find.side_effect = exceptions.CommandError()
self.volume_sdk_client.find_volume.side_effect = (
exceptions.CommandError()
)
arglist = [
self.backup.id,
self.backup.volume_id,
@ -528,7 +532,7 @@ class TestBackupRestore(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.sdk_client.restore_backup.assert_called_with(
self.volume_sdk_client.restore_backup.assert_called_with(
self.backup.id,
volume_id=None,
name=self.backup.volume_id,
@ -549,7 +553,7 @@ class TestBackupRestore(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.sdk_client.restore_backup.assert_called_with(
self.volume_sdk_client.restore_backup.assert_called_with(
self.backup.id,
volume_id=self.volume.id,
name=None,
@ -588,9 +592,7 @@ class TestBackupSet(TestBackupLegacy):
self.cmd = volume_backup.SetVolumeBackup(self.app, None)
def test_backup_set_name(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.9'
)
self.volume_client.api_version = api_versions.APIVersion('3.9')
arglist = [
'--name',
@ -612,9 +614,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIsNone(result)
def test_backup_set_name_pre_v39(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'--name',
@ -633,9 +633,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIn("--os-volume-api-version 3.9 or greater", str(exc))
def test_backup_set_description(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.9'
)
self.volume_client.api_version = api_versions.APIVersion('3.9')
arglist = [
'--description',
@ -659,9 +657,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIsNone(result)
def test_backup_set_description_pre_v39(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'--description',
@ -710,9 +706,7 @@ class TestBackupSet(TestBackupLegacy):
)
def test_backup_set_no_property(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.43'
)
self.volume_client.api_version = api_versions.APIVersion('3.43')
arglist = [
'--no-property',
@ -736,9 +730,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIsNone(result)
def test_backup_set_no_property_pre_v343(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.42'
)
self.volume_client.api_version = api_versions.APIVersion('3.42')
arglist = [
'--no-property',
@ -756,9 +748,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
def test_backup_set_property(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.43'
)
self.volume_client.api_version = api_versions.APIVersion('3.43')
arglist = [
'--property',
@ -783,9 +773,7 @@ class TestBackupSet(TestBackupLegacy):
self.assertIsNone(result)
def test_backup_set_property_pre_v343(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.42'
)
self.volume_client.api_version = api_versions.APIVersion('3.42')
arglist = [
'--property',
@ -818,9 +806,7 @@ class TestBackupUnset(TestBackupLegacy):
self.cmd = volume_backup.UnsetVolumeBackup(self.app, None)
def test_backup_unset_property(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.43'
)
self.volume_client.api_version = api_versions.APIVersion('3.43')
arglist = [
'--property',
@ -845,9 +831,7 @@ class TestBackupUnset(TestBackupLegacy):
self.assertIsNone(result)
def test_backup_unset_property_pre_v343(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.42'
)
self.volume_client.api_version = api_versions.APIVersion('3.42')
arglist = [
'--property',
@ -917,7 +901,7 @@ class TestBackupShow(TestBackup):
def setUp(self):
super().setUp()
self.sdk_client.get_backup.return_value = self.backup
self.volume_sdk_client.get_backup.return_value = self.backup
# Get the command object to test
self.cmd = volume_backup.ShowVolumeBackup(self.app, None)
@ -927,7 +911,7 @@ class TestBackupShow(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.get_backup.assert_called_with(self.backup.id)
self.volume_sdk_client.get_backup.assert_called_with(self.backup.id)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)

View File

@ -20,7 +20,7 @@ class TestVolumeHost(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.host_mock = self.app.client_manager.volume.services
self.host_mock = self.volume_client.services
self.host_mock.reset_mock()

View File

@ -29,9 +29,9 @@ class TestVolumeSnapshot(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.project_mock = self.app.client_manager.identity.projects
self.project_mock.reset_mock()

View File

@ -29,11 +29,11 @@ class TestTransfer(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the TransferManager Mock
self.transfer_mock = self.app.client_manager.volume.transfers
self.transfer_mock = self.volume_client.transfers
self.transfer_mock.reset_mock()
# Get a shortcut to the VolumeManager Mock
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
@ -177,9 +177,7 @@ class TestTransferCreate(TestTransfer):
self.assertEqual(self.data, data)
def test_transfer_create_with_no_snapshots(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.55'
)
self.volume_client.api_version = api_versions.APIVersion('3.55')
arglist = [
'--no-snapshots',
@ -201,9 +199,7 @@ class TestTransferCreate(TestTransfer):
self.assertEqual(self.data, data)
def test_transfer_create_pre_v355(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.54'
)
self.volume_client.api_version = api_versions.APIVersion('3.54')
arglist = [
'--no-snapshots',

View File

@ -29,16 +29,14 @@ class TestType(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volume_types_mock = self.app.client_manager.volume.volume_types
self.volume_types_mock = self.volume_client.volume_types
self.volume_types_mock.reset_mock()
self.volume_type_access_mock = (
self.app.client_manager.volume.volume_type_access
)
self.volume_type_access_mock = self.volume_client.volume_type_access
self.volume_type_access_mock.reset_mock()
self.volume_encryption_types_mock = (
self.app.client_manager.volume.volume_encryption_types
self.volume_client.volume_encryption_types
)
self.volume_encryption_types_mock.reset_mock()

View File

@ -15,8 +15,8 @@ from unittest import mock
import uuid
from cinderclient import api_versions
from openstack.block_storage.v3 import _proxy
from openstack.block_storage.v3 import availability_zone as _availability_zone
from openstack.block_storage.v3 import block_storage_summary as _summary
from openstack.block_storage.v3 import extension as _extension
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
@ -63,6 +63,15 @@ class TestVolume(utils.TestCommand):
self.app.client_manager.volume = FakeVolumeClient(
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
)
self.volume_client = self.app.client_manager.volume
# TODO(stephenfin): Rename to 'volume_client' once all commands are
# migrated to SDK
self.app.client_manager.sdk_connection.volume = mock.Mock(
spec=_proxy.Proxy,
)
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
)
@ -605,14 +614,3 @@ def create_snapshot_manage_list_records(count=2):
)
return snapshot_manage_list
def get_one_block_storage_summary(total_size, metadata=None):
summary_dict = {
'total_count': 2,
'total_size': total_size,
}
if metadata:
summary_dict['metadata'] = metadata
block_storage_summary = _summary.BlockStorageSummary(**summary_dict)
return block_storage_summary

View File

@ -24,7 +24,7 @@ class TestBlockStorage(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the BlockStorageWorkerManager Mock
self.worker_mock = self.app.client_manager.volume.workers
self.worker_mock = self.volume_client.workers
self.worker_mock.reset_mock()
@ -40,9 +40,7 @@ class TestBlockStorageCleanup(TestBlockStorage):
self.cmd = block_storage_cleanup.BlockStorageCleanup(self.app, None)
def test_cleanup(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.24'
)
self.volume_client.api_version = api_versions.APIVersion('3.24')
arglist = []
verifylist = [
@ -98,9 +96,7 @@ class TestBlockStorageCleanup(TestBlockStorage):
)
def test_cleanup_with_args(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.24'
)
self.volume_client.api_version = api_versions.APIVersion('3.24')
fake_cluster = 'fake-cluster'
fake_host = 'fake-host'

View File

@ -22,7 +22,7 @@ class TestBlockStorageCluster(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the BlockStorageClusterManager Mock
self.cluster_mock = self.app.client_manager.volume.clusters
self.cluster_mock = self.volume_client.clusters
self.cluster_mock.reset_mock()
@ -41,9 +41,7 @@ class TestBlockStorageClusterList(TestBlockStorageCluster):
)
def test_cluster_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = []
verifylist = [
@ -84,9 +82,7 @@ class TestBlockStorageClusterList(TestBlockStorageCluster):
)
def test_cluster_list_with_full_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--cluster',
@ -156,9 +152,7 @@ class TestBlockStorageClusterList(TestBlockStorageCluster):
)
def test_cluster_list_pre_v37(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.6'
)
self.volume_client.api_version = api_versions.APIVersion('3.6')
arglist = []
verifylist = [
@ -221,9 +215,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
self.cmd = block_storage_cluster.SetBlockStorageCluster(self.app, None)
def test_cluster_set(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--enable',
@ -250,9 +242,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
)
def test_cluster_set_disable_with_reason(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--binary',
@ -282,9 +272,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
)
def test_cluster_set_only_with_disable_reason(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--disable-reason',
@ -307,9 +295,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
)
def test_cluster_set_enable_with_disable_reason(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--enable',
@ -333,9 +319,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
)
def test_cluster_set_pre_v37(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.6'
)
self.volume_client.api_version = api_versions.APIVersion('3.6')
arglist = [
'--enable',
@ -401,9 +385,7 @@ class TestBlockStorageClusterShow(TestBlockStorageCluster):
)
def test_cluster_show(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.7'
)
self.volume_client.api_version = api_versions.APIVersion('3.7')
arglist = [
'--binary',
@ -427,9 +409,7 @@ class TestBlockStorageClusterShow(TestBlockStorageCluster):
)
def test_cluster_show_pre_v37(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.6'
)
self.volume_client.api_version = api_versions.APIVersion('3.6')
arglist = [
'--binary',

View File

@ -26,7 +26,7 @@ class TestService(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the ServiceManager Mock
self.service_mock = self.app.client_manager.volume.services
self.service_mock = self.volume_client.services
self.service_mock.reset_mock()
@ -42,9 +42,7 @@ class TestBlockStorageLogLevelList(TestService):
self.cmd = service.BlockStorageLogLevelList(self.app, None)
def test_block_storage_log_level_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
'--host',
self.service_log.host,
@ -115,9 +113,7 @@ class TestBlockStorageLogLevelList(TestService):
)
def test_block_storage_log_level_list_invalid_service_name(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
'--host',
self.service_log.host,
@ -152,9 +148,7 @@ class TestBlockStorageLogLevelSet(TestService):
self.cmd = service.BlockStorageLogLevelSet(self.app, None)
def test_block_storage_log_level_set(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
'ERROR',
'--host',
@ -208,9 +202,7 @@ class TestBlockStorageLogLevelSet(TestService):
)
def test_block_storage_log_level_set_invalid_service_name(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
'ERROR',
'--host',
@ -237,9 +229,7 @@ class TestBlockStorageLogLevelSet(TestService):
@ddt.data('WARNING', 'info', 'Error', 'debuG', 'fake-log-level')
def test_block_storage_log_level_set_log_level(self, log_level):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
log_level,
'--host',

View File

@ -25,9 +25,9 @@ class TestBlockStorageManage(v2_volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.snapshots_mock = self.app.client_manager.volume.volume_snapshots
self.snapshots_mock = self.volume_client.volume_snapshots
self.snapshots_mock.reset_mock()
@ -47,9 +47,7 @@ class TestBlockStorageVolumeManage(TestBlockStorageManage):
)
def test_block_storage_volume_manage_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'fake_host',
]
@ -106,9 +104,7 @@ class TestBlockStorageVolumeManage(TestBlockStorageManage):
)
def test_block_storage_volume_manage_list__pre_v317(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.16'
)
self.volume_client.api_version = api_versions.APIVersion('3.16')
arglist = [
'--cluster',
'fake_cluster',
@ -127,9 +123,7 @@ class TestBlockStorageVolumeManage(TestBlockStorageManage):
self.assertIn('--cluster', str(exc))
def test_block_storage_volume_manage_list__host_and_cluster(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.17'
)
self.volume_client.api_version = api_versions.APIVersion('3.17')
arglist = [
'fake_host',
'--cluster',
@ -152,9 +146,7 @@ class TestBlockStorageVolumeManage(TestBlockStorageManage):
def test_block_storage_volume_manage_list__detailed(self):
"""This option is deprecated."""
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'--detailed',
'True',
@ -294,9 +286,7 @@ class TestBlockStorageSnapshotManage(TestBlockStorageManage):
)
def test_block_storage_snapshot_manage_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'fake_host',
]
@ -355,9 +345,7 @@ class TestBlockStorageSnapshotManage(TestBlockStorageManage):
)
def test_block_storage_snapshot_manage_list__pre_v317(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.16'
)
self.volume_client.api_version = api_versions.APIVersion('3.16')
arglist = [
'--cluster',
'fake_cluster',
@ -376,9 +364,7 @@ class TestBlockStorageSnapshotManage(TestBlockStorageManage):
self.assertIn('--cluster', str(exc))
def test_block_storage_snapshot_manage_list__host_and_cluster(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.17'
)
self.volume_client.api_version = api_versions.APIVersion('3.17')
arglist = [
'fake_host',
'--cluster',
@ -400,10 +386,7 @@ class TestBlockStorageSnapshotManage(TestBlockStorageManage):
)
def test_block_storage_snapshot_manage_list__detailed(self):
"""This option is deprecated."""
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.8'
)
self.volume_client.api_version = api_versions.APIVersion('3.8')
arglist = [
'--detailed',
'True',

View File

@ -22,9 +22,7 @@ class TestBlockStorageResourceFilter(volume_fakes.TestVolume):
super().setUp()
# Get a shortcut to the ResourceFilterManager Mock
self.resource_filter_mock = (
self.app.client_manager.volume.resource_filters
)
self.resource_filter_mock = self.volume_client.resource_filters
self.resource_filter_mock.reset_mock()
@ -47,9 +45,7 @@ class TestBlockStorageResourceFilterList(TestBlockStorageResourceFilter):
)
def test_resource_filter_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.33'
)
self.volume_client.api_version = api_versions.APIVersion('3.33')
arglist = []
verifylist = []
@ -72,9 +68,7 @@ class TestBlockStorageResourceFilterList(TestBlockStorageResourceFilter):
self.resource_filter_mock.list.assert_called_with()
def test_resource_filter_list_pre_v333(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = []
verifylist = []
@ -107,9 +101,7 @@ class TestBlockStorageResourceFilterShow(TestBlockStorageResourceFilter):
)
def test_resource_filter_show(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.33'
)
self.volume_client.api_version = api_versions.APIVersion('3.33')
arglist = [
self.fake_resource_filter.resource,
@ -133,9 +125,7 @@ class TestBlockStorageResourceFilterShow(TestBlockStorageResourceFilter):
self.resource_filter_mock.list.assert_called_with(resource='volume')
def test_resource_filter_show_pre_v333(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.32'
)
self.volume_client.api_version = api_versions.APIVersion('3.32')
arglist = [
self.fake_resource_filter.resource,

View File

@ -16,30 +16,29 @@ import copy
from unittest import mock
from cinderclient import api_versions
from openstack.block_storage.v3 import block_storage_summary as _summary
from openstack.block_storage.v3 import snapshot as _snapshot
from openstack.block_storage.v3 import volume as _volume
from openstack.test import fakes as sdk_fakes
from openstack import utils as sdk_utils
from osc_lib.cli import format_columns
from osc_lib import exceptions
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.tests.unit.volume.v3 import fakes as v3_fakes
from openstackclient.tests.unit.volume.v3 import fakes
from openstackclient.volume.v3 import volume
class BaseVolumeTest(volume_fakes.TestVolume):
class BaseVolumeTest(fakes.TestVolume):
def setUp(self):
super().setUp()
self.app.client_manager.sdk_connection = mock.Mock()
self.app.client_manager.sdk_connection.volume = mock.Mock()
self.sdk_client = self.app.client_manager.sdk_connection.volume
patcher = mock.patch.object(
sdk_utils, 'supports_microversion', return_value=True
)
self.addCleanup(patcher.stop)
self.supports_microversion_mock = patcher.start()
self._set_mock_microversion(
self.app.client_manager.volume.api_version.get_string()
self.volume_client.api_version.get_string()
)
def _set_mock_microversion(self, mock_v):
@ -60,12 +59,14 @@ class TestVolumeSummary(BaseVolumeTest):
def setUp(self):
super().setUp()
self.mock_vol_1 = volume_fakes.create_one_volume()
self.mock_vol_2 = volume_fakes.create_one_volume()
block_storage_summary = v3_fakes.get_one_block_storage_summary(
self.mock_vol_1.size + self.mock_vol_2.size
self.volume_a = sdk_fakes.generate_fake_resource(_volume.Volume)
self.volume_b = sdk_fakes.generate_fake_resource(_volume.Volume)
self.summary = sdk_fakes.generate_fake_resource(
_summary.BlockStorageSummary,
total_count=2,
total_size=self.volume_a.size + self.volume_b.size,
)
self.sdk_client.summary.return_value = block_storage_summary
self.volume_sdk_client.summary.return_value = self.summary
# Get the command object to test
self.cmd = volume.VolumeSummary(self.app, None)
@ -82,11 +83,11 @@ class TestVolumeSummary(BaseVolumeTest):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.summary.assert_called_once_with(True)
self.volume_sdk_client.summary.assert_called_once_with(True)
self.assertEqual(self.columns, columns)
datalist = (2, self.mock_vol_1.size + self.mock_vol_2.size)
datalist = (2, self.volume_a.size + self.volume_b.size)
self.assertCountEqual(datalist, tuple(data))
def test_volume_summary_pre_312(self):
@ -108,11 +109,14 @@ class TestVolumeSummary(BaseVolumeTest):
def test_volume_summary_with_metadata(self):
self._set_mock_microversion('3.36')
combine_meta = {**self.mock_vol_1.metadata, **self.mock_vol_2.metadata}
block_storage_summary = v3_fakes.get_one_block_storage_summary(
self.mock_vol_1.size + self.mock_vol_2.size, metadata=combine_meta
metadata = {**self.volume_a.metadata, **self.volume_b.metadata}
self.summary = sdk_fakes.generate_fake_resource(
_summary.BlockStorageSummary,
total_count=2,
total_size=self.volume_a.size + self.volume_b.size,
metadata=metadata,
)
self.sdk_client.summary.return_value = block_storage_summary
self.volume_sdk_client.summary.return_value = self.summary
new_cols = copy.deepcopy(self.columns)
new_cols.extend(['Metadata'])
@ -127,14 +131,14 @@ class TestVolumeSummary(BaseVolumeTest):
columns, data = self.cmd.take_action(parsed_args)
self.sdk_client.summary.assert_called_once_with(True)
self.volume_sdk_client.summary.assert_called_once_with(True)
self.assertEqual(new_cols, columns)
datalist = (
2,
self.mock_vol_1.size + self.mock_vol_2.size,
format_columns.DictColumn(combine_meta),
self.volume_a.size + self.volume_b.size,
format_columns.DictColumn(metadata),
)
self.assertCountEqual(datalist, tuple(data))
@ -143,20 +147,23 @@ class TestVolumeRevertToSnapshot(BaseVolumeTest):
def setUp(self):
super().setUp()
self.mock_volume = volume_fakes.create_one_volume()
self.mock_snapshot = volume_fakes.create_one_snapshot(
attrs={'volume_id': self.mock_volume.id}
self.volume = sdk_fakes.generate_fake_resource(_volume.Volume)
self.snapshot = sdk_fakes.generate_fake_resource(
_snapshot.Snapshot,
volume_id=self.volume.id,
)
self.volume_sdk_client.find_volume.return_value = self.volume
self.volume_sdk_client.find_snapshot.return_value = self.snapshot
# Get the command object to test
self.cmd = volume.VolumeRevertToSnapshot(self.app, None)
def test_volume_revert_to_snapshot_pre_340(self):
arglist = [
self.mock_snapshot.id,
self.snapshot.id,
]
verifylist = [
('snapshot', self.mock_snapshot.id),
('snapshot', self.snapshot.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -170,29 +177,24 @@ class TestVolumeRevertToSnapshot(BaseVolumeTest):
def test_volume_revert_to_snapshot(self):
self._set_mock_microversion('3.40')
arglist = [
self.mock_snapshot.id,
self.snapshot.id,
]
verifylist = [
('snapshot', self.mock_snapshot.id),
('snapshot', self.snapshot.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
with mock.patch.object(
self.sdk_client, 'find_volume', return_value=self.mock_volume
), mock.patch.object(
self.sdk_client, 'find_snapshot', return_value=self.mock_snapshot
):
self.cmd.take_action(parsed_args)
self.cmd.take_action(parsed_args)
self.sdk_client.revert_volume_to_snapshot.assert_called_once_with(
self.mock_volume,
self.mock_snapshot,
)
self.sdk_client.find_volume.assert_called_with(
self.mock_volume.id,
ignore_missing=False,
)
self.sdk_client.find_snapshot.assert_called_with(
self.mock_snapshot.id,
ignore_missing=False,
)
self.volume_sdk_client.revert_volume_to_snapshot.assert_called_once_with(
self.volume,
self.snapshot,
)
self.volume_sdk_client.find_volume.assert_called_with(
self.volume.id,
ignore_missing=False,
)
self.volume_sdk_client.find_snapshot.assert_called_with(
self.snapshot.id,
ignore_missing=False,
)

View File

@ -24,12 +24,10 @@ class TestVolumeAttachment(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock = self.volume_client.volumes
self.volumes_mock.reset_mock()
self.volume_attachments_mock = (
self.app.client_manager.volume.attachments
)
self.volume_attachments_mock = self.volume_client.attachments
self.volume_attachments_mock.reset_mock()
self.projects_mock = self.app.client_manager.identity.projects
@ -80,9 +78,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
self.cmd = volume_attachment.CreateVolumeAttachment(self.app, None)
def test_volume_attachment_create(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.27'
)
self.volume_client.api_version = api_versions.APIVersion('3.27')
arglist = [
self.volume.id,
@ -117,9 +113,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
self.assertCountEqual(self.data, data)
def test_volume_attachment_create_with_connect(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.54'
)
self.volume_client.api_version = api_versions.APIVersion('3.54')
arglist = [
self.volume.id,
@ -182,9 +176,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
self.assertCountEqual(self.data, data)
def test_volume_attachment_create_pre_v327(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.26'
)
self.volume_client.api_version = api_versions.APIVersion('3.26')
arglist = [
self.volume.id,
@ -204,9 +196,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
)
def test_volume_attachment_create_with_mode_pre_v354(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.53'
)
self.volume_client.api_version = api_versions.APIVersion('3.53')
arglist = [
self.volume.id,
@ -229,9 +219,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
)
def test_volume_attachment_create_with_connect_missing_arg(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.54'
)
self.volume_client.api_version = api_versions.APIVersion('3.54')
arglist = [
self.volume.id,
@ -266,9 +254,7 @@ class TestVolumeAttachmentDelete(TestVolumeAttachment):
self.cmd = volume_attachment.DeleteVolumeAttachment(self.app, None)
def test_volume_attachment_delete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.27'
)
self.volume_client.api_version = api_versions.APIVersion('3.27')
arglist = [
self.volume_attachment.id,
@ -286,9 +272,7 @@ class TestVolumeAttachmentDelete(TestVolumeAttachment):
self.assertIsNone(result)
def test_volume_attachment_delete_pre_v327(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.26'
)
self.volume_client.api_version = api_versions.APIVersion('3.26')
arglist = [
self.volume_attachment.id,
@ -340,9 +324,7 @@ class TestVolumeAttachmentSet(TestVolumeAttachment):
self.cmd = volume_attachment.SetVolumeAttachment(self.app, None)
def test_volume_attachment_set(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.27'
)
self.volume_client.api_version = api_versions.APIVersion('3.27')
arglist = [
self.volume_attachment.id,
@ -394,9 +376,7 @@ class TestVolumeAttachmentSet(TestVolumeAttachment):
self.assertCountEqual(self.data, data)
def test_volume_attachment_set_pre_v327(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.26'
)
self.volume_client.api_version = api_versions.APIVersion('3.26')
arglist = [
self.volume_attachment.id,
@ -428,9 +408,7 @@ class TestVolumeAttachmentComplete(TestVolumeAttachment):
self.cmd = volume_attachment.CompleteVolumeAttachment(self.app, None)
def test_volume_attachment_complete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.44'
)
self.volume_client.api_version = api_versions.APIVersion('3.44')
arglist = [
self.volume_attachment.id,
@ -448,9 +426,7 @@ class TestVolumeAttachmentComplete(TestVolumeAttachment):
self.assertIsNone(result)
def test_volume_attachment_complete_pre_v344(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.43'
)
self.volume_client.api_version = api_versions.APIVersion('3.43')
arglist = [
self.volume_attachment.id,
@ -499,9 +475,7 @@ class TestVolumeAttachmentList(TestVolumeAttachment):
self.cmd = volume_attachment.ListVolumeAttachment(self.app, None)
def test_volume_attachment_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.27'
)
self.volume_client.api_version = api_versions.APIVersion('3.27')
arglist = []
verifylist = [
@ -530,9 +504,7 @@ class TestVolumeAttachmentList(TestVolumeAttachment):
self.assertCountEqual(tuple(self.data), data)
def test_volume_attachment_list_with_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.27'
)
self.volume_client.api_version = api_versions.APIVersion('3.27')
arglist = [
'--project',
@ -572,9 +544,7 @@ class TestVolumeAttachmentList(TestVolumeAttachment):
self.assertCountEqual(tuple(self.data), data)
def test_volume_attachment_list_pre_v327(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.26'
)
self.volume_client.api_version = api_versions.APIVersion('3.26')
arglist = []
verifylist = [

View File

@ -24,20 +24,16 @@ class TestVolumeGroup(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volume_groups_mock = self.app.client_manager.volume.groups
self.volume_groups_mock = self.volume_client.groups
self.volume_groups_mock.reset_mock()
self.volume_group_types_mock = (
self.app.client_manager.volume.group_types
)
self.volume_group_types_mock = self.volume_client.group_types
self.volume_group_types_mock.reset_mock()
self.volume_types_mock = self.app.client_manager.volume.volume_types
self.volume_types_mock = self.volume_client.volume_types
self.volume_types_mock.reset_mock()
self.volume_group_snapshots_mock = (
self.app.client_manager.volume.group_snapshots
)
self.volume_group_snapshots_mock = self.volume_client.group_snapshots
self.volume_group_snapshots_mock.reset_mock()
@ -100,9 +96,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
self.cmd = volume_group.CreateVolumeGroup(self.app, None)
def test_volume_group_create(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
'--volume-group-type',
@ -138,9 +132,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_create__legacy(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
self.fake_volume_group_type.id,
@ -180,9 +172,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
)
def test_volume_group_create_no_volume_type(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
'--volume-group-type',
@ -204,9 +194,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
)
def test_volume_group_create_with_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
'--volume-group-type',
@ -248,9 +236,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_create_pre_v313(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.12'
)
self.volume_client.api_version = api_versions.APIVersion('3.12')
arglist = [
'--volume-group-type',
@ -275,9 +261,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
)
def test_volume_group_create_from_source_group(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
'--source-group',
@ -306,9 +290,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_create_from_group_snapshot(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
'--group-snapshot',
@ -337,9 +319,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_create_from_src_pre_v314(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
'--source-group',
@ -358,9 +338,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
)
def test_volume_group_create_from_src_source_group_group_snapshot(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
'--source-group',
@ -398,9 +376,7 @@ class TestVolumeGroupDelete(TestVolumeGroup):
self.cmd = volume_group.DeleteVolumeGroup(self.app, None)
def test_volume_group_delete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
self.fake_volume_group.id,
@ -421,9 +397,7 @@ class TestVolumeGroupDelete(TestVolumeGroup):
self.assertIsNone(result)
def test_volume_group_delete_pre_v313(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.12'
)
self.volume_client.api_version = api_versions.APIVersion('3.12')
arglist = [
self.fake_volume_group.id,
@ -481,9 +455,7 @@ class TestVolumeGroupSet(TestVolumeGroup):
self.cmd = volume_group.SetVolumeGroup(self.app, None)
def test_volume_group_set(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
self.fake_volume_group.id,
@ -510,9 +482,7 @@ class TestVolumeGroupSet(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_with_enable_replication_option(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.38'
)
self.volume_client.api_version = api_versions.APIVersion('3.38')
arglist = [
self.fake_volume_group.id,
@ -533,9 +503,7 @@ class TestVolumeGroupSet(TestVolumeGroup):
self.assertCountEqual(self.data, data)
def test_volume_group_set_pre_v313(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.12'
)
self.volume_client.api_version = api_versions.APIVersion('3.12')
arglist = [
self.fake_volume_group.id,
@ -559,9 +527,7 @@ class TestVolumeGroupSet(TestVolumeGroup):
)
def test_volume_group_with_enable_replication_option_pre_v338(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.37'
)
self.volume_client.api_version = api_versions.APIVersion('3.37')
arglist = [
self.fake_volume_group.id,
@ -606,9 +572,7 @@ class TestVolumeGroupList(TestVolumeGroup):
self.cmd = volume_group.ListVolumeGroup(self.app, None)
def test_volume_group_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
'--all-projects',
@ -629,9 +593,7 @@ class TestVolumeGroupList(TestVolumeGroup):
self.assertCountEqual(tuple(self.data), data)
def test_volume_group_list_pre_v313(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.12'
)
self.volume_client.api_version = api_versions.APIVersion('3.12')
arglist = [
'--all-projects',
@ -661,9 +623,7 @@ class TestVolumeGroupFailover(TestVolumeGroup):
self.cmd = volume_group.FailoverVolumeGroup(self.app, None)
def test_volume_group_failover(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.38'
)
self.volume_client.api_version = api_versions.APIVersion('3.38')
arglist = [
self.fake_volume_group.id,
@ -688,9 +648,7 @@ class TestVolumeGroupFailover(TestVolumeGroup):
self.assertIsNone(result)
def test_volume_group_failover_pre_v338(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.37'
)
self.volume_client.api_version = api_versions.APIVersion('3.37')
arglist = [
self.fake_volume_group.id,

View File

@ -21,12 +21,10 @@ class TestVolumeGroupSnapshot(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volume_groups_mock = self.app.client_manager.volume.groups
self.volume_groups_mock = self.volume_client.groups
self.volume_groups_mock.reset_mock()
self.volume_group_snapshots_mock = (
self.app.client_manager.volume.group_snapshots
)
self.volume_group_snapshots_mock = self.volume_client.group_snapshots
self.volume_group_snapshots_mock.reset_mock()
@ -69,9 +67,7 @@ class TestVolumeGroupSnapshotCreate(TestVolumeGroupSnapshot):
)
def test_volume_group_snapshot_create(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
self.fake_volume_group.id,
@ -97,9 +93,7 @@ class TestVolumeGroupSnapshotCreate(TestVolumeGroupSnapshot):
self.assertCountEqual(self.data, data)
def test_volume_group_snapshot_create_with_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
self.fake_volume_group.id,
@ -129,9 +123,7 @@ class TestVolumeGroupSnapshotCreate(TestVolumeGroupSnapshot):
self.assertCountEqual(self.data, data)
def test_volume_group_snapshot_create_pre_v314(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
self.fake_volume_group.id,
@ -169,9 +161,7 @@ class TestVolumeGroupSnapshotDelete(TestVolumeGroupSnapshot):
)
def test_volume_group_snapshot_delete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
self.fake_volume_group_snapshot.id,
@ -189,9 +179,7 @@ class TestVolumeGroupSnapshotDelete(TestVolumeGroupSnapshot):
self.assertIsNone(result)
def test_volume_group_snapshot_delete_pre_v314(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = [
self.fake_volume_group_snapshot.id,
@ -238,9 +226,7 @@ class TestVolumeGroupSnapshotList(TestVolumeGroupSnapshot):
)
def test_volume_group_snapshot_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.14'
)
self.volume_client.api_version = api_versions.APIVersion('3.14')
arglist = [
'--all-projects',
@ -261,9 +247,7 @@ class TestVolumeGroupSnapshotList(TestVolumeGroupSnapshot):
self.assertCountEqual(tuple(self.data), data)
def test_volume_group_snapshot_list_pre_v314(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.13'
)
self.volume_client.api_version = api_versions.APIVersion('3.13')
arglist = []
verifylist = [

View File

@ -24,9 +24,7 @@ class TestVolumeGroupType(volume_fakes.TestVolume):
def setUp(self):
super().setUp()
self.volume_group_types_mock = (
self.app.client_manager.volume.group_types
)
self.volume_group_types_mock = self.volume_client.group_types
self.volume_group_types_mock.reset_mock()
@ -60,9 +58,7 @@ class TestVolumeGroupTypeCreate(TestVolumeGroupType):
self.cmd = volume_group_type.CreateVolumeGroupType(self.app, None)
def test_volume_group_type_create(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
self.fake_volume_group_type.name,
@ -83,9 +79,7 @@ class TestVolumeGroupTypeCreate(TestVolumeGroupType):
self.assertCountEqual(self.data, data)
def test_volume_group_type_create_with_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
self.fake_volume_group_type.name,
@ -109,9 +103,7 @@ class TestVolumeGroupTypeCreate(TestVolumeGroupType):
self.assertCountEqual(self.data, data)
def test_volume_group_type_create_pre_v311(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.10'
)
self.volume_client.api_version = api_versions.APIVersion('3.10')
arglist = [
self.fake_volume_group_type.name,
@ -145,9 +137,7 @@ class TestVolumeGroupTypeDelete(TestVolumeGroupType):
self.cmd = volume_group_type.DeleteVolumeGroupType(self.app, None)
def test_volume_group_type_delete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
self.fake_volume_group_type.id,
@ -165,9 +155,7 @@ class TestVolumeGroupTypeDelete(TestVolumeGroupType):
self.assertIsNone(result)
def test_volume_group_type_delete_pre_v311(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.10'
)
self.volume_client.api_version = api_versions.APIVersion('3.10')
arglist = [
self.fake_volume_group_type.id,
@ -222,9 +210,7 @@ class TestVolumeGroupTypeSet(TestVolumeGroupType):
self.cmd = volume_group_type.SetVolumeGroupType(self.app, None)
def test_volume_group_type_set(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
self.fake_volume_group_type.set_keys.return_value = None
@ -263,9 +249,7 @@ class TestVolumeGroupTypeSet(TestVolumeGroupType):
self.assertCountEqual(self.data, data)
def test_volume_group_type_with_no_property_option(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
self.fake_volume_group_type.id,
@ -296,9 +280,7 @@ class TestVolumeGroupTypeSet(TestVolumeGroupType):
self.assertCountEqual(self.data, data)
def test_volume_group_type_set_pre_v311(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.10'
)
self.volume_client.api_version = api_versions.APIVersion('3.10')
arglist = [
self.fake_volume_group_type.id,
@ -355,9 +337,7 @@ class TestVolumeGroupTypeUnset(TestVolumeGroupType):
self.cmd = volume_group_type.UnsetVolumeGroupType(self.app, None)
def test_volume_group_type_unset(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
self.fake_volume_group_type.id,
@ -385,9 +365,7 @@ class TestVolumeGroupTypeUnset(TestVolumeGroupType):
self.assertCountEqual(self.data, data)
def test_volume_group_type_unset_pre_v311(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.10'
)
self.volume_client.api_version = api_versions.APIVersion('3.10')
arglist = [
self.fake_volume_group_type.id,
@ -440,9 +418,7 @@ class TestVolumeGroupTypeList(TestVolumeGroupType):
self.cmd = volume_group_type.ListVolumeGroupType(self.app, None)
def test_volume_group_type_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = []
verifylist = [
@ -457,9 +433,7 @@ class TestVolumeGroupTypeList(TestVolumeGroupType):
self.assertCountEqual(tuple(self.data), data)
def test_volume_group_type_list_with_default_option(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.11'
)
self.volume_client.api_version = api_versions.APIVersion('3.11')
arglist = [
'--default',
@ -476,9 +450,7 @@ class TestVolumeGroupTypeList(TestVolumeGroupType):
self.assertCountEqual(tuple([self.data[0]]), data)
def test_volume_group_type_list_pre_v311(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.10'
)
self.volume_client.api_version = api_versions.APIVersion('3.10')
arglist = []
verifylist = []

View File

@ -27,7 +27,7 @@ class TestVolumeMessage(volume_fakes.TestVolume):
self.projects_mock = self.app.client_manager.identity.projects
self.projects_mock.reset_mock()
self.volume_messages_mock = self.app.client_manager.volume.messages
self.volume_messages_mock = self.volume_client.messages
self.volume_messages_mock.reset_mock()
@ -46,9 +46,7 @@ class TestVolumeMessageDelete(TestVolumeMessage):
self.cmd = volume_message.DeleteMessage(self.app, None)
def test_message_delete(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = [
self.fake_messages[0].id,
@ -66,9 +64,7 @@ class TestVolumeMessageDelete(TestVolumeMessage):
self.assertIsNone(result)
def test_message_delete_multiple_messages(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = [
self.fake_messages[0].id,
@ -88,9 +84,7 @@ class TestVolumeMessageDelete(TestVolumeMessage):
self.assertIsNone(result)
def test_message_delete_multiple_messages_with_exception(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = [
self.fake_messages[0].id,
@ -120,9 +114,7 @@ class TestVolumeMessageDelete(TestVolumeMessage):
self.assertEqual(2, self.volume_messages_mock.delete.call_count)
def test_message_delete_pre_v33(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.2'
)
self.volume_client.api_version = api_versions.APIVersion('3.2')
arglist = [
self.fake_messages[0].id,
@ -180,9 +172,7 @@ class TestVolumeMessageList(TestVolumeMessage):
self.cmd = volume_message.ListMessages(self.app, None)
def test_message_list(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = []
verifylist = [
@ -206,9 +196,7 @@ class TestVolumeMessageList(TestVolumeMessage):
self.assertCountEqual(self.data, list(data))
def test_message_list_with_options(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = [
'--project',
@ -239,9 +227,7 @@ class TestVolumeMessageList(TestVolumeMessage):
self.assertCountEqual(self.data, list(data))
def test_message_list_pre_v33(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.2'
)
self.volume_client.api_version = api_versions.APIVersion('3.2')
arglist = []
verifylist = [
@ -294,9 +280,7 @@ class TestVolumeMessageShow(TestVolumeMessage):
self.cmd = volume_message.ShowMessage(self.app, None)
def test_message_show(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.3'
)
self.volume_client.api_version = api_versions.APIVersion('3.3')
arglist = [self.fake_message.id]
verifylist = [('message_id', self.fake_message.id)]
@ -309,9 +293,7 @@ class TestVolumeMessageShow(TestVolumeMessage):
self.assertEqual(self.data, data)
def test_message_show_pre_v33(self):
self.app.client_manager.volume.api_version = api_versions.APIVersion(
'3.2'
)
self.volume_client.api_version = api_versions.APIVersion('3.2')
arglist = [self.fake_message.id]
verifylist = [('message_id', self.fake_message.id)]