tests: Remove unnecessary nesting of volume resources

Change-Id: I210ce7534d161e89115e5cb96e42ab7f27170aa1
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2022-09-29 18:42:26 +01:00 committed by Stephen Finucane
parent d7f431be50
commit 1aaaa6f1d1
34 changed files with 2299 additions and 2488 deletions

View File

@ -78,7 +78,7 @@ def _build_network_az_datalist(network_az, long_datalist=False):
class TestAvailabilityZone(utils.TestCommand):
def setUp(self):
super(TestAvailabilityZone, self).setUp()
super().setUp()
compute_client = compute_fakes.FakeComputev2Client(
endpoint=fakes.AUTH_URL,
@ -113,8 +113,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
compute_azs = \
compute_fakes.FakeAvailabilityZone.create_availability_zones()
volume_azs = \
volume_fakes.FakeAvailabilityZone.create_availability_zones(count=1)
volume_azs = volume_fakes.create_availability_zones(count=1)
network_azs = network_fakes.create_availability_zones()
short_columnslist = ('Zone Name', 'Zone Status')
@ -128,7 +127,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
)
def setUp(self):
super(TestAvailabilityZoneList, self).setUp()
super().setUp()
self.compute_azs_mock.list.return_value = self.compute_azs
self.volume_azs_mock.list.return_value = self.volume_azs

View File

@ -26,7 +26,7 @@ from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
class TestExtension(utils.TestCommand):
def setUp(self):
super(TestExtension, self).setUp()
super().setUp()
identity_client = identity_fakes.FakeIdentityv2Client(
endpoint=fakes.AUTH_URL,
@ -66,13 +66,13 @@ class TestExtensionList(TestExtension):
long_columns = ('Name', 'Alias', 'Description', 'Namespace', 'Updated',
'Links')
volume_extension = volume_fakes.FakeExtension.create_one_extension()
volume_extension = volume_fakes.create_one_extension()
identity_extension = identity_fakes.FakeExtension.create_one_extension()
compute_extension = compute_fakes.FakeExtension.create_one_extension()
network_extension = network_fakes.FakeExtension.create_one_extension()
def setUp(self):
super(TestExtensionList, self).setUp()
super().setUp()
self.identity_extensions_mock.list.return_value = [
self.identity_extension]
@ -310,7 +310,7 @@ class TestExtensionShow(TestExtension):
)
def setUp(self):
super(TestExtensionShow, self).setUp()
super().setUp()
self.cmd = extension.ShowExtension(self.app, None)

View File

@ -33,7 +33,7 @@ class TestComputeLimits(compute_fakes.TestComputev2):
]
def setUp(self):
super(TestComputeLimits, self).setUp()
super().setUp()
self.app.client_manager.volume_endpoint_enabled = False
self.compute = self.app.client_manager.compute
@ -87,7 +87,7 @@ class TestVolumeLimits(volume_fakes.TestVolume):
]
def setUp(self):
super(TestVolumeLimits, self).setUp()
super().setUp()
self.app.client_manager.compute_endpoint_enabled = False
self.volume = self.app.client_manager.volume

View File

@ -26,7 +26,7 @@ from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
class TestProjectPurgeInit(tests_utils.TestCommand):
def setUp(self):
super(TestProjectPurgeInit, self).setUp()
super().setUp()
compute_client = compute_fakes.FakeComputev2Client(
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
@ -71,12 +71,12 @@ class TestProjectPurge(TestProjectPurgeInit):
project = identity_fakes.FakeProject.create_one_project()
server = compute_fakes.FakeServer.create_one_server()
image = image_fakes.create_one_image()
volume = volume_fakes.FakeVolume.create_one_volume()
backup = volume_fakes.FakeBackup.create_one_backup()
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
volume = volume_fakes.create_one_volume()
backup = volume_fakes.create_one_backup()
snapshot = volume_fakes.create_one_snapshot()
def setUp(self):
super(TestProjectPurge, self).setUp()
super().setUp()
self.projects_mock.get.return_value = self.project
self.projects_mock.delete.return_value = None
self.images_mock.list.return_value = [self.image]

View File

@ -176,12 +176,12 @@ class TestQuotaList(TestQuota):
)
self.volume_quotas = [
volume_fakes.FakeQuota.create_one_vol_quota(),
volume_fakes.FakeQuota.create_one_vol_quota(),
volume_fakes.create_one_vol_quota(),
volume_fakes.create_one_vol_quota(),
]
self.volume_default_quotas = [
volume_fakes.FakeQuota.create_one_default_vol_quota(),
volume_fakes.FakeQuota.create_one_default_vol_quota(),
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(
@ -280,8 +280,7 @@ class TestQuotaList(TestQuota):
sorted(detailed_reference_data), sorted(ret_quotas))
def test_quota_list_details_volume(self):
detailed_quota = (
volume_fakes.FakeQuota.create_one_detailed_quota())
detailed_quota = volume_fakes.create_one_detailed_quota()
detailed_column_header = (
'Resource',
@ -567,7 +566,7 @@ class TestQuotaList(TestQuota):
self.volume.quotas.get = mock.Mock(
side_effect=[
self.volume_quotas[0],
volume_fakes.FakeQuota.create_one_default_vol_quota(),
volume_fakes.create_one_default_vol_quota(),
],
)
@ -591,7 +590,7 @@ class TestQuotaList(TestQuota):
self.volume.quotas.get = mock.Mock(
side_effect=[
self.volume_quotas[0],
volume_fakes.FakeQuota.create_one_default_vol_quota(),
volume_fakes.create_one_default_vol_quota(),
],
)
@ -1046,10 +1045,9 @@ class TestQuotaShow(TestQuota):
loaded=True,
)
self.volume_quota = volume_fakes.FakeQuota.create_one_vol_quota()
self.volume_quota = volume_fakes.create_one_vol_quota()
self.volume_quotas_mock.get.return_value = self.volume_quota
self.volume_default_quota = \
volume_fakes.FakeQuota.create_one_default_vol_quota()
self.volume_default_quota = volume_fakes.create_one_default_vol_quota()
self.volume_quotas_mock.defaults.return_value = \
self.volume_default_quota
self.volume_quotas_class_mock.get.return_value = FakeQuotaResource(
@ -1217,8 +1215,7 @@ class TestQuotaShow(TestQuota):
self.compute_quota = \
compute_fakes.FakeQuota.create_one_comp_detailed_quota()
self.compute_quotas_mock.get.return_value = self.compute_quota
self.volume_quota = \
volume_fakes.FakeQuota.create_one_detailed_quota()
self.volume_quota = volume_fakes.create_one_detailed_quota()
self.volume_quotas_mock.get.return_value = self.volume_quota
self.network.get_quota.return_value = \
network_fakes.FakeQuota.create_one_net_detailed_quota()

View File

@ -153,7 +153,7 @@ class TestServer(compute_fakes.TestComputev2):
return servers
def setup_sdk_volumes_mock(self, count):
volumes = volume_fakes.FakeVolume.create_sdk_volumes(count=count)
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
@ -1444,10 +1444,10 @@ class TestServerCreate(TestServer):
self.flavor = compute_fakes.FakeFlavor.create_one_flavor()
self.flavors_mock.get.return_value = self.flavor
self.volume = volume_fakes.FakeVolume.create_one_volume()
self.volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = self.volume
self.snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
self.snapshot = volume_fakes.create_one_snapshot()
self.snapshots_mock.get.return_value = self.snapshot
# Get the command object to test

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ from openstackclient.volume.v1 import qos_specs
class TestQos(volume_fakes.TestVolumev1):
def setUp(self):
super(TestQos, self).setUp()
super().setUp()
self.qos_mock = self.app.client_manager.volume.qos_specs
self.qos_mock.reset_mock()
@ -39,11 +39,11 @@ class TestQos(volume_fakes.TestVolumev1):
class TestQosAssociate(TestQos):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
qos_spec = volume_fakes.FakeQos.create_one_qos()
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosAssociate, self).setUp()
super().setUp()
self.qos_mock.get.return_value = self.qos_spec
self.types_mock.get.return_value = self.volume_type
@ -80,8 +80,8 @@ class TestQosCreate(TestQos):
)
def setUp(self):
super(TestQosCreate, self).setUp()
self.new_qos_spec = volume_fakes.FakeQos.create_one_qos()
super().setUp()
self.new_qos_spec = volume_fakes.create_one_qos()
self.datalist = (
self.new_qos_spec.consumer,
self.new_qos_spec.id,
@ -160,13 +160,13 @@ class TestQosCreate(TestQos):
class TestQosDelete(TestQos):
qos_specs = volume_fakes.FakeQos.create_qoses(count=2)
qos_specs = volume_fakes.create_qoses(count=2)
def setUp(self):
super(TestQosDelete, self).setUp()
super().setUp()
self.qos_mock.get = (
volume_fakes.FakeQos.get_qoses(self.qos_specs))
volume_fakes.get_qoses(self.qos_specs))
# Get the command object to test
self.cmd = qos_specs.DeleteQos(self.app, None)
@ -263,11 +263,11 @@ class TestQosDelete(TestQos):
class TestQosDisassociate(TestQos):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
qos_spec = volume_fakes.FakeQos.create_one_qos()
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosDisassociate, self).setUp()
super().setUp()
self.qos_mock.get.return_value = self.qos_spec
self.types_mock.get.return_value = self.volume_type
@ -311,8 +311,8 @@ class TestQosDisassociate(TestQos):
class TestQosList(TestQos):
qos_specs = volume_fakes.FakeQos.create_qoses(count=2)
qos_association = volume_fakes.FakeQos.create_one_qos_association()
qos_specs = volume_fakes.create_qoses(count=2)
qos_association = volume_fakes.create_one_qos_association()
columns = (
'ID',
@ -332,7 +332,7 @@ class TestQosList(TestQos):
))
def setUp(self):
super(TestQosList, self).setUp()
super().setUp()
self.qos_mock.list.return_value = self.qos_specs
self.qos_mock.get_associations.return_value = [self.qos_association]
@ -382,10 +382,10 @@ class TestQosList(TestQos):
class TestQosSet(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosSet, self).setUp()
super().setUp()
self.qos_mock.get.return_value = self.qos_spec
# Get the command object to test
@ -414,11 +414,11 @@ class TestQosSet(TestQos):
class TestQosShow(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_association = volume_fakes.FakeQos.create_one_qos_association()
qos_spec = volume_fakes.create_one_qos()
qos_association = volume_fakes.create_one_qos_association()
def setUp(self):
super(TestQosShow, self).setUp()
super().setUp()
self.qos_mock.get.return_value = self.qos_spec
self.qos_mock.get_associations.return_value = [self.qos_association]
# Get the command object to test
@ -459,10 +459,10 @@ class TestQosShow(TestQos):
class TestQosUnset(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosUnset, self).setUp()
super().setUp()
self.qos_mock.get.return_value = self.qos_spec
# Get the command object to test

View File

@ -14,14 +14,14 @@
from osc_lib import exceptions
from openstackclient.tests.unit.volume.v1 import fakes as service_fakes
from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
from openstackclient.volume.v1 import service
class TestService(service_fakes.TestVolumev1):
class TestService(volume_fakes.TestVolumev1):
def setUp(self):
super(TestService, self).setUp()
super().setUp()
# Get a shortcut to the ServiceManager Mock
self.service_mock = self.app.client_manager.volume.services
@ -31,10 +31,10 @@ class TestService(service_fakes.TestVolumev1):
class TestServiceList(TestService):
# The service to be listed
services = service_fakes.FakeService.create_one_service()
services = volume_fakes.create_one_service()
def setUp(self):
super(TestServiceList, self).setUp()
super().setUp()
self.service_mock.list.return_value = [self.services]
@ -144,10 +144,10 @@ class TestServiceList(TestService):
class TestServiceSet(TestService):
service = service_fakes.FakeService.create_one_service()
service = volume_fakes.create_one_service()
def setUp(self):
super(TestServiceSet, self).setUp()
super().setUp()
self.service_mock.enable.return_value = self.service
self.service_mock.disable.return_value = self.service

View File

@ -18,14 +18,14 @@ from unittest.mock import call
from osc_lib import exceptions
from osc_lib import utils
from openstackclient.tests.unit.volume.v1 import fakes as transfer_fakes
from openstackclient.tests.unit.volume.v1 import fakes as volume_fakes
from openstackclient.volume.v1 import volume_transfer_request
class TestTransfer(transfer_fakes.TestVolumev1):
class TestTransfer(volume_fakes.TestVolumev1):
def setUp(self):
super(TestTransfer, self).setUp()
super().setUp()
# Get a shortcut to the TransferManager Mock
self.transfer_mock = self.app.client_manager.volume.transfers
@ -45,10 +45,9 @@ class TestTransferAccept(TestTransfer):
)
def setUp(self):
super(TestTransferAccept, self).setUp()
super().setUp()
self.volume_transfer = (
transfer_fakes.FakeTransfer.create_one_transfer())
self.volume_transfer = volume_fakes.create_one_transfer()
self.data = (
self.volume_transfer.id,
self.volume_transfer.name,
@ -103,7 +102,7 @@ class TestTransferAccept(TestTransfer):
class TestTransferCreate(TestTransfer):
volume = transfer_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
columns = (
'auth_key',
@ -114,12 +113,14 @@ class TestTransferCreate(TestTransfer):
)
def setUp(self):
super(TestTransferCreate, self).setUp()
super().setUp()
self.volume_transfer = transfer_fakes.FakeTransfer.create_one_transfer(
attrs={'volume_id': self.volume.id,
'auth_key': 'key',
'created_at': 'time'}
self.volume_transfer = volume_fakes.create_one_transfer(
attrs={
'volume_id': self.volume.id,
'auth_key': 'key',
'created_at': 'time',
},
)
self.data = (
self.volume_transfer.auth_key,
@ -173,13 +174,14 @@ class TestTransferCreate(TestTransfer):
class TestTransferDelete(TestTransfer):
volume_transfers = transfer_fakes.FakeTransfer.create_transfers(count=2)
volume_transfers = volume_fakes.create_transfers(count=2)
def setUp(self):
super(TestTransferDelete, self).setUp()
super().setUp()
self.transfer_mock.get = (
transfer_fakes.FakeTransfer.get_transfers(self.volume_transfers))
self.transfer_mock.get = volume_fakes.get_transfers(
self.volume_transfers,
)
self.transfer_mock.delete.return_value = None
# Get the command object to mock
@ -252,10 +254,10 @@ class TestTransferDelete(TestTransfer):
class TestTransferList(TestTransfer):
# The Transfers to be listed
volume_transfers = transfer_fakes.FakeTransfer.create_one_transfer()
volume_transfers = volume_fakes.create_one_transfer()
def setUp(self):
super(TestTransferList, self).setUp()
super().setUp()
self.transfer_mock.list.return_value = [self.volume_transfers]
@ -346,11 +348,10 @@ class TestTransferShow(TestTransfer):
)
def setUp(self):
super(TestTransferShow, self).setUp()
super().setUp()
self.volume_transfer = (
transfer_fakes.FakeTransfer.create_one_transfer(
attrs={'created_at': 'time'})
self.volume_transfer = volume_fakes.create_one_transfer(
attrs={'created_at': 'time'}
)
self.data = (
self.volume_transfer.created_at,

View File

@ -27,7 +27,7 @@ from openstackclient.volume.v1 import volume_type
class TestType(volume_fakes.TestVolumev1):
def setUp(self):
super(TestType, self).setUp()
super().setUp()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock.reset_mock()
@ -47,11 +47,11 @@ class TestTypeCreate(TestType):
)
def setUp(self):
super(TestTypeCreate, self).setUp()
super().setUp()
self.new_volume_type = \
volume_fakes.FakeVolumeType.create_one_volume_type(
methods={'set_keys': {'myprop': 'myvalue'}})
self.new_volume_type = volume_fakes.create_one_volume_type(
methods={'set_keys': {'myprop': 'myvalue'}},
)
self.data = (
self.new_volume_type.description,
self.new_volume_type.id,
@ -87,12 +87,12 @@ class TestTypeCreate(TestType):
'key_size': '128',
'control_location': 'front-end',
}
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
attrs=encryption_info)
self.new_volume_type = \
volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'encryption': encryption_info})
encryption_type = volume_fakes.create_one_encryption_volume_type(
attrs=encryption_info,
)
self.new_volume_type = volume_fakes.create_one_volume_type(
attrs={'encryption': encryption_info},
)
self.types_mock.create.return_value = self.new_volume_type
self.encryption_types_mock.create.return_value = encryption_type
encryption_columns = (
@ -145,13 +145,12 @@ class TestTypeCreate(TestType):
class TestTypeDelete(TestType):
volume_types = volume_fakes.FakeVolumeType.create_volume_types(count=2)
volume_types = volume_fakes.create_volume_types(count=2)
def setUp(self):
super(TestTypeDelete, self).setUp()
super().setUp()
self.types_mock.get = volume_fakes.FakeVolumeType.get_volume_types(
self.volume_types)
self.types_mock.get = volume_fakes.get_volume_types(self.volume_types)
self.types_mock.delete.return_value = None
# Get the command object to mock
@ -221,7 +220,7 @@ class TestTypeDelete(TestType):
class TestTypeList(TestType):
volume_types = volume_fakes.FakeVolumeType.create_volume_types()
volume_types = volume_fakes.create_volume_types()
columns = [
"ID",
@ -252,7 +251,7 @@ class TestTypeList(TestType):
))
def setUp(self):
super(TestTypeList, self).setUp()
super().setUp()
self.types_mock.list.return_value = self.volume_types
self.encryption_types_mock.create.return_value = None
@ -288,9 +287,9 @@ class TestTypeList(TestType):
self.assertCountEqual(self.data_long, list(data))
def test_type_list_with_encryption(self):
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
attrs={'volume_type_id': self.volume_types[0].id})
encryption_type = volume_fakes.create_one_encryption_volume_type(
attrs={'volume_type_id': self.volume_types[0].id},
)
encryption_info = {
'provider': 'LuksEncryptor',
'cipher': None,
@ -335,11 +334,12 @@ class TestTypeList(TestType):
class TestTypeSet(TestType):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
methods={'set_keys': None})
volume_type = volume_fakes.create_one_volume_type(
methods={'set_keys': None},
)
def setUp(self):
super(TestTypeSet, self).setUp()
super().setUp()
self.types_mock.get.return_value = self.volume_type
@ -441,9 +441,9 @@ class TestTypeShow(TestType):
)
def setUp(self):
super(TestTypeShow, self).setUp()
super().setUp()
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
self.volume_type = volume_fakes.create_one_volume_type()
self.data = (
self.volume_type.description,
self.volume_type.id,
@ -474,16 +474,16 @@ class TestTypeShow(TestType):
self.assertCountEqual(self.data, data)
def test_type_show_with_encryption(self):
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type()
encryption_type = volume_fakes.create_one_encryption_volume_type()
encryption_info = {
'provider': 'LuksEncryptor',
'cipher': None,
'key_size': None,
'control_location': 'front-end',
}
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'encryption': encryption_info})
self.volume_type = volume_fakes.create_one_volume_type(
attrs={'encryption': encryption_info},
)
self.types_mock.get.return_value = self.volume_type
self.encryption_types_mock.get.return_value = encryption_type
encryption_columns = (
@ -521,11 +521,12 @@ class TestTypeShow(TestType):
class TestTypeUnset(TestType):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
methods={'unset_keys': None})
volume_type = volume_fakes.create_one_volume_type(
methods={'unset_keys': None},
)
def setUp(self):
super(TestTypeUnset, self).setUp()
super().setUp()
self.types_mock.get.return_value = self.volume_type
@ -599,7 +600,7 @@ class TestTypeUnset(TestType):
class TestColumns(TestType):
def test_encryption_info_column_with_info(self):
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
fake_volume_type = volume_fakes.create_one_volume_type()
type_id = fake_volume_type.id
encryption_info = {
@ -615,7 +616,7 @@ class TestColumns(TestType):
self.assertEqual(encryption_info, col.machine_readable())
def test_encryption_info_column_without_info(self):
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
fake_volume_type = volume_fakes.create_one_volume_type()
type_id = fake_volume_type.id
col = volume_type.EncryptionInfoColumn(type_id, {})

View File

@ -31,7 +31,7 @@ from openstackclient.volume.v1 import volume
class TestVolume(volume_fakes.TestVolumev1):
def setUp(self):
super(TestVolume, self).setUp()
super().setUp()
# Get a shortcut to the VolumeManager Mock
self.volumes_mock = self.app.client_manager.volume.volumes
@ -50,11 +50,9 @@ class TestVolume(volume_fakes.TestVolumev1):
self.images_mock.reset_mock()
def setup_volumes_mock(self, count):
volumes = volume_fakes.FakeVolume.create_volumes(count=count)
volumes = volume_fakes.create_volumes(count=count)
self.volumes_mock.get = volume_fakes.FakeVolume.get_volumes(
volumes,
0)
self.volumes_mock.get = volume_fakes.get_volumes(volumes, 0)
return volumes
@ -79,8 +77,8 @@ class TestVolumeCreate(TestVolume):
)
def setUp(self):
super(TestVolumeCreate, self).setUp()
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
super().setUp()
self.new_volume = volume_fakes.create_one_volume()
self.datalist = (
self.new_volume.attachments,
self.new_volume.availability_zone,
@ -635,7 +633,7 @@ class TestVolumeCreate(TestVolume):
class TestVolumeDelete(TestVolume):
def setUp(self):
super(TestVolumeDelete, self).setUp()
super().setUp()
self.volumes_mock.delete.return_value = None
@ -725,7 +723,7 @@ class TestVolumeDelete(TestVolume):
class TestVolumeList(TestVolume):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
columns = (
'ID',
'Name',
@ -744,7 +742,7 @@ class TestVolumeList(TestVolume):
)
def setUp(self):
super(TestVolumeList, self).setUp()
super().setUp()
self.volumes_mock.list.return_value = [self._volume]
@ -921,10 +919,10 @@ class TestVolumeList(TestVolume):
class TestVolumeMigrate(TestVolume):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
def setUp(self):
super(TestVolumeMigrate, self).setUp()
super().setUp()
self.volumes_mock.get.return_value = self._volume
self.volumes_mock.migrate_volume.return_value = None
@ -983,10 +981,10 @@ class TestVolumeMigrate(TestVolume):
class TestVolumeSet(TestVolume):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
def setUp(self):
super(TestVolumeSet, self).setUp()
super().setUp()
self.volumes_mock.get.return_value = self._volume
@ -1243,8 +1241,8 @@ class TestVolumeShow(TestVolume):
)
def setUp(self):
super(TestVolumeShow, self).setUp()
self._volume = volume_fakes.FakeVolume.create_one_volume()
super().setUp()
self._volume = volume_fakes.create_one_volume()
self.datalist = (
self._volume.attachments,
self._volume.availability_zone,
@ -1300,10 +1298,10 @@ class TestVolumeShow(TestVolume):
class TestVolumeUnset(TestVolume):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
def setUp(self):
super(TestVolumeUnset, self).setUp()
super().setUp()
self.volumes_mock.get.return_value = self._volume
@ -1346,7 +1344,7 @@ class TestVolumeUnset(TestVolume):
class TestColumns(TestVolume):
def test_attachments_column_without_server_cache(self):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
server_id = _volume.attachments[0]['server_id']
device = _volume.attachments[0]['device']
@ -1356,7 +1354,7 @@ class TestColumns(TestVolume):
self.assertEqual(_volume.attachments, col.machine_readable())
def test_attachments_column_with_server_cache(self):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
server_id = _volume.attachments[0]['server_id']
device = _volume.attachments[0]['device']

View File

@ -25,7 +25,7 @@ from openstackclient.volume.v1 import volume_backup
class TestBackup(volume_fakes.TestVolumev1):
def setUp(self):
super(TestBackup, self).setUp()
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock.reset_mock()
@ -39,7 +39,7 @@ class TestBackup(volume_fakes.TestVolumev1):
class TestBackupCreate(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
columns = (
'availability_zone',
@ -55,9 +55,10 @@ class TestBackupCreate(TestBackup):
)
def setUp(self):
super(TestBackupCreate, self).setUp()
self.new_backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': self.volume.id})
super().setUp()
self.new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': self.volume.id},
)
self.data = (
self.new_backup.availability_zone,
self.new_backup.container,
@ -129,13 +130,12 @@ class TestBackupCreate(TestBackup):
class TestBackupDelete(TestBackup):
backups = volume_fakes.FakeBackup.create_backups(count=2)
backups = volume_fakes.create_backups(count=2)
def setUp(self):
super(TestBackupDelete, self).setUp()
super().setUp()
self.backups_mock.get = (
volume_fakes.FakeBackup.get_backups(self.backups))
self.backups_mock.get = volume_fakes.get_backups(self.backups)
self.backups_mock.delete.return_value = None
# Get the command object to mock
@ -205,9 +205,11 @@ class TestBackupDelete(TestBackup):
class TestBackupList(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backups = volume_fakes.FakeBackup.create_backups(
attrs={'volume_id': volume.display_name}, count=3)
volume = volume_fakes.create_one_volume()
backups = volume_fakes.create_backups(
attrs={'volume_id': volume.display_name},
count=3,
)
columns = [
'ID',
@ -245,7 +247,7 @@ class TestBackupList(TestBackup):
))
def setUp(self):
super(TestBackupList, self).setUp()
super().setUp()
self.volumes_mock.list.return_value = [self.volume]
self.backups_mock.list.return_value = self.backups
@ -314,9 +316,10 @@ class TestBackupList(TestBackup):
class TestBackupRestore(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': volume.id})
volume = volume_fakes.create_one_volume()
backup = volume_fakes.create_one_backup(
attrs={'volume_id': volume.id},
)
def setUp(self):
super().setUp()
@ -324,7 +327,7 @@ class TestBackupRestore(TestBackup):
self.backups_mock.get.return_value = self.backup
self.volumes_mock.get.return_value = self.volume
self.restores_mock.restore.return_value = (
volume_fakes.FakeVolume.create_one_volume(
volume_fakes.create_one_volume(
{'id': self.volume['id']},
)
)
@ -400,8 +403,8 @@ class TestBackupShow(TestBackup):
)
def setUp(self):
super(TestBackupShow, self).setUp()
self.backup = volume_fakes.FakeBackup.create_one_backup()
super().setUp()
self.backup = volume_fakes.create_one_backup()
self.data = (
self.backup.availability_zone,
self.backup.container,

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ from openstackclient.volume.v2 import backup_record
class TestBackupRecord(volume_fakes.TestVolume):
def setUp(self):
super(TestBackupRecord, self).setUp()
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock.reset_mock()
@ -27,12 +27,13 @@ class TestBackupRecord(volume_fakes.TestVolume):
class TestBackupRecordExport(TestBackupRecord):
new_backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'})
new_record = volume_fakes.FakeBackup.create_backup_record()
new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
)
new_record = volume_fakes.create_backup_record()
def setUp(self):
super(TestBackupRecordExport, self).setUp()
super().setUp()
self.backups_mock.export_record.return_value = self.new_record
self.backups_mock.get.return_value = self.new_backup
@ -81,12 +82,13 @@ class TestBackupRecordExport(TestBackupRecord):
class TestBackupRecordImport(TestBackupRecord):
new_backup = volume_fakes.FakeBackup.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'})
new_import = volume_fakes.FakeBackup.import_backup_record()
new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
)
new_import = volume_fakes.import_backup_record()
def setUp(self):
super(TestBackupRecordImport, self).setUp()
super().setUp()
self.backups_mock.import_record.return_value = self.new_import

View File

@ -26,7 +26,7 @@ from openstackclient.volume.v2 import consistency_group
class TestConsistencyGroup(volume_fakes.TestVolume):
def setUp(self):
super(TestConsistencyGroup, self).setUp()
super().setUp()
# Get a shortcut to the TransferManager Mock
self.consistencygroups_mock = (
@ -47,11 +47,10 @@ class TestConsistencyGroup(volume_fakes.TestVolume):
class TestConsistencyGroupAddVolume(TestConsistencyGroup):
_consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
_consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super(TestConsistencyGroupAddVolume, self).setUp()
super().setUp()
self.consistencygroups_mock.get.return_value = (
self._consistency_group)
@ -60,7 +59,7 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
consistency_group.AddVolumeToConsistencyGroup(self.app, None)
def test_add_one_volume_to_consistency_group(self):
volume = volume_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = volume
arglist = [
self._consistency_group.id,
@ -85,8 +84,8 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
self.assertIsNone(result)
def test_add_multiple_volumes_to_consistency_group(self):
volumes = volume_fakes.FakeVolume.create_volumes(count=2)
self.volumes_mock.get = volume_fakes.FakeVolume.get_volumes(volumes)
volumes = volume_fakes.create_volumes(count=2)
self.volumes_mock.get = volume_fakes.get_volumes(volumes)
arglist = [
self._consistency_group.id,
volumes[0].id,
@ -112,8 +111,9 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
@mock.patch.object(consistency_group.LOG, 'error')
def test_add_multiple_volumes_to_consistency_group_with_exception(
self, mock_error):
volume = volume_fakes.FakeVolume.create_one_volume()
self, mock_error,
):
volume = volume_fakes.create_one_volume()
arglist = [
self._consistency_group.id,
volume.id,
@ -148,13 +148,10 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
class TestConsistencyGroupCreate(TestConsistencyGroup):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
new_consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
volume_type = volume_fakes.create_one_volume_type()
new_consistency_group = volume_fakes.create_one_consistency_group()
consistency_group_snapshot = (
volume_fakes.
FakeConsistencyGroupSnapshot.
create_one_consistency_group_snapshot()
volume_fakes.create_one_consistency_group_snapshot()
)
columns = (
@ -177,7 +174,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
)
def setUp(self):
super(TestConsistencyGroupCreate, self).setUp()
super().setUp()
self.consistencygroups_mock.create.return_value = (
self.new_consistency_group)
self.consistencygroups_mock.create_from_src.return_value = (
@ -313,13 +310,14 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
class TestConsistencyGroupDelete(TestConsistencyGroup):
consistency_groups =\
volume_fakes.FakeConsistencyGroup.create_consistency_groups(count=2)
volume_fakes.create_consistency_groups(count=2)
def setUp(self):
super(TestConsistencyGroupDelete, self).setUp()
super().setUp()
self.consistencygroups_mock.get = volume_fakes.FakeConsistencyGroup.\
get_consistency_groups(self.consistency_groups)
self.consistencygroups_mock.get = volume_fakes.get_consistency_groups(
self.consistency_groups,
)
self.consistencygroups_mock.delete.return_value = None
# Get the command object to mock
@ -409,8 +407,7 @@ class TestConsistencyGroupDelete(TestConsistencyGroup):
class TestConsistencyGroupList(TestConsistencyGroup):
consistency_groups = (
volume_fakes.FakeConsistencyGroup.create_consistency_groups(count=2))
consistency_groups = volume_fakes.create_consistency_groups(count=2)
columns = [
'ID',
@ -444,7 +441,7 @@ class TestConsistencyGroupList(TestConsistencyGroup):
))
def setUp(self):
super(TestConsistencyGroupList, self).setUp()
super().setUp()
self.consistencygroups_mock.list.return_value = self.consistency_groups
# Get the command to test
@ -502,11 +499,10 @@ class TestConsistencyGroupList(TestConsistencyGroup):
class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
_consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
_consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super(TestConsistencyGroupRemoveVolume, self).setUp()
super().setUp()
self.consistencygroups_mock.get.return_value = (
self._consistency_group)
@ -515,7 +511,7 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
consistency_group.RemoveVolumeFromConsistencyGroup(self.app, None)
def test_remove_one_volume_from_consistency_group(self):
volume = volume_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = volume
arglist = [
self._consistency_group.id,
@ -540,8 +536,8 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
self.assertIsNone(result)
def test_remove_multi_volumes_from_consistency_group(self):
volumes = volume_fakes.FakeVolume.create_volumes(count=2)
self.volumes_mock.get = volume_fakes.FakeVolume.get_volumes(volumes)
volumes = volume_fakes.create_volumes(count=2)
self.volumes_mock.get = volume_fakes.get_volumes(volumes)
arglist = [
self._consistency_group.id,
volumes[0].id,
@ -567,8 +563,10 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
@mock.patch.object(consistency_group.LOG, 'error')
def test_remove_multiple_volumes_from_consistency_group_with_exception(
self, mock_error):
volume = volume_fakes.FakeVolume.create_one_volume()
self,
mock_error,
):
volume = volume_fakes.create_one_volume()
arglist = [
self._consistency_group.id,
volume.id,
@ -603,11 +601,10 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
class TestConsistencyGroupSet(TestConsistencyGroup):
consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super(TestConsistencyGroupSet, self).setUp()
super().setUp()
self.consistencygroups_mock.get.return_value = (
self.consistency_group)
@ -677,10 +674,9 @@ class TestConsistencyGroupShow(TestConsistencyGroup):
)
def setUp(self):
super(TestConsistencyGroupShow, self).setUp()
super().setUp()
self.consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
self.consistency_group = volume_fakes.create_one_consistency_group()
self.data = (
self.consistency_group.availability_zone,
self.consistency_group.created_at,

View File

@ -35,12 +35,9 @@ class TestConsistencyGroupSnapshot(volume_fakes.TestVolume):
class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
_consistency_group_snapshot = (
volume_fakes.
FakeConsistencyGroupSnapshot.
create_one_consistency_group_snapshot()
volume_fakes.create_one_consistency_group_snapshot()
)
consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
consistency_group = volume_fakes.create_one_consistency_group()
columns = (
'consistencygroup_id',
@ -124,16 +121,16 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
class TestConsistencyGroupSnapshotDelete(TestConsistencyGroupSnapshot):
consistency_group_snapshots = (
volume_fakes.FakeConsistencyGroupSnapshot.
create_consistency_group_snapshots(count=2)
volume_fakes.create_consistency_group_snapshots(count=2)
)
def setUp(self):
super(TestConsistencyGroupSnapshotDelete, self).setUp()
self.cgsnapshots_mock.get = (
volume_fakes.FakeConsistencyGroupSnapshot.
get_consistency_group_snapshots(self.consistency_group_snapshots)
volume_fakes.get_consistency_group_snapshots(
self.consistency_group_snapshots
)
)
self.cgsnapshots_mock.delete.return_value = None
@ -178,12 +175,9 @@ class TestConsistencyGroupSnapshotDelete(TestConsistencyGroupSnapshot):
class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
consistency_group_snapshots = (
volume_fakes.FakeConsistencyGroupSnapshot.
create_consistency_group_snapshots(count=2)
)
consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group()
volume_fakes.create_consistency_group_snapshots(count=2)
)
consistency_group = volume_fakes.create_one_consistency_group()
columns = [
'ID',
@ -306,9 +300,7 @@ class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
class TestConsistencyGroupSnapshotShow(TestConsistencyGroupSnapshot):
_consistency_group_snapshot = (
volume_fakes.
FakeConsistencyGroupSnapshot.
create_one_consistency_group_snapshot()
volume_fakes.create_one_consistency_group_snapshot()
)
columns = (

View File

@ -39,8 +39,8 @@ class TestQos(volume_fakes.TestVolume):
class TestQosAssociate(TestQos):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
qos_spec = volume_fakes.FakeQos.create_one_qos()
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosAssociate, self).setUp()
@ -82,7 +82,7 @@ class TestQosCreate(TestQos):
def setUp(self):
super(TestQosCreate, self).setUp()
self.new_qos_spec = volume_fakes.FakeQos.create_one_qos()
self.new_qos_spec = volume_fakes.create_one_qos()
self.qos_mock.create.return_value = self.new_qos_spec
self.data = (
@ -164,13 +164,13 @@ class TestQosCreate(TestQos):
class TestQosDelete(TestQos):
qos_specs = volume_fakes.FakeQos.create_qoses(count=2)
qos_specs = volume_fakes.create_qoses(count=2)
def setUp(self):
super(TestQosDelete, self).setUp()
self.qos_mock.get = (
volume_fakes.FakeQos.get_qoses(self.qos_specs))
volume_fakes.get_qoses(self.qos_specs))
# Get the command object to test
self.cmd = qos_specs.DeleteQos(self.app, None)
@ -255,8 +255,8 @@ class TestQosDelete(TestQos):
class TestQosDisassociate(TestQos):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
qos_spec = volume_fakes.FakeQos.create_one_qos()
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosDisassociate, self).setUp()
@ -303,8 +303,8 @@ class TestQosDisassociate(TestQos):
class TestQosList(TestQos):
qos_specs = volume_fakes.FakeQos.create_qoses(count=2)
qos_association = volume_fakes.FakeQos.create_one_qos_association()
qos_specs = volume_fakes.create_qoses(count=2)
qos_association = volume_fakes.create_one_qos_association()
columns = (
'ID',
@ -374,7 +374,7 @@ class TestQosList(TestQos):
class TestQosSet(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosSet, self).setUp()
@ -406,8 +406,8 @@ class TestQosSet(TestQos):
class TestQosShow(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_association = volume_fakes.FakeQos.create_one_qos_association()
qos_spec = volume_fakes.create_one_qos()
qos_association = volume_fakes.create_one_qos_association()
columns = (
'associations',
@ -454,7 +454,7 @@ class TestQosShow(TestQos):
class TestQosUnset(TestQos):
qos_spec = volume_fakes.FakeQos.create_one_qos()
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
super(TestQosUnset, self).setUp()

View File

@ -14,14 +14,14 @@
from osc_lib import exceptions
from openstackclient.tests.unit.volume.v2 import fakes as service_fakes
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.volume.v2 import service
class TestService(service_fakes.TestVolume):
class TestService(volume_fakes.TestVolume):
def setUp(self):
super(TestService, self).setUp()
super().setUp()
# Get a shortcut to the ServiceManager Mock
self.service_mock = self.app.client_manager.volume.services
@ -31,10 +31,10 @@ class TestService(service_fakes.TestVolume):
class TestServiceList(TestService):
# The service to be listed
services = service_fakes.FakeService.create_one_service()
services = volume_fakes.create_one_service()
def setUp(self):
super(TestServiceList, self).setUp()
super().setUp()
self.service_mock.list.return_value = [self.services]
@ -144,10 +144,10 @@ class TestServiceList(TestService):
class TestServiceSet(TestService):
service = service_fakes.FakeService.create_one_service()
service = volume_fakes.create_one_service()
def setUp(self):
super(TestServiceSet, self).setUp()
super().setUp()
self.service_mock.enable.return_value = self.service
self.service_mock.disable.return_value = self.service

View File

@ -28,7 +28,7 @@ from openstackclient.volume.v2 import volume_type
class TestType(volume_fakes.TestVolume):
def setUp(self):
super(TestType, self).setUp()
super().setUp()
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock.reset_mock()
@ -56,10 +56,9 @@ class TestTypeCreate(TestType):
)
def setUp(self):
super(TestTypeCreate, self).setUp()
super().setUp()
self.new_volume_type = \
volume_fakes.FakeVolumeType.create_one_volume_type()
self.new_volume_type = volume_fakes.create_one_volume_type()
self.data = (
self.new_volume_type.description,
self.new_volume_type.id,
@ -144,12 +143,12 @@ class TestTypeCreate(TestType):
'key_size': '128',
'control_location': 'front-end',
}
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
attrs=encryption_info)
self.new_volume_type = \
volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'encryption': encryption_info})
encryption_type = volume_fakes.create_one_encryption_volume_type(
attrs=encryption_info,
)
self.new_volume_type = volume_fakes.create_one_volume_type(
attrs={'encryption': encryption_info},
)
self.types_mock.create.return_value = self.new_volume_type
self.encryption_types_mock.create.return_value = encryption_type
encryption_columns = (
@ -203,13 +202,14 @@ class TestTypeCreate(TestType):
class TestTypeDelete(TestType):
volume_types = volume_fakes.FakeVolumeType.create_volume_types(count=2)
volume_types = volume_fakes.create_volume_types(count=2)
def setUp(self):
super(TestTypeDelete, self).setUp()
super().setUp()
self.types_mock.get = volume_fakes.FakeVolumeType.get_volume_types(
self.volume_types)
self.types_mock.get = volume_fakes.get_volume_types(
self.volume_types,
)
self.types_mock.delete.return_value = None
# Get the command object to mock
@ -278,7 +278,7 @@ class TestTypeDelete(TestType):
class TestTypeList(TestType):
volume_types = volume_fakes.FakeVolumeType.create_volume_types()
volume_types = volume_fakes.create_volume_types()
columns = [
"ID",
@ -312,7 +312,7 @@ class TestTypeList(TestType):
))
def setUp(self):
super(TestTypeList, self).setUp()
super().setUp()
self.types_mock.list.return_value = self.volume_types
self.types_mock.default.return_value = self.volume_types[0]
@ -388,9 +388,9 @@ class TestTypeList(TestType):
self.assertCountEqual(self.data_with_default_type, list(data))
def test_type_list_with_encryption(self):
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
attrs={'volume_type_id': self.volume_types[0].id})
encryption_type = volume_fakes.create_one_encryption_volume_type(
attrs={'volume_type_id': self.volume_types[0].id},
)
encryption_info = {
'provider': 'LuksEncryptor',
'cipher': None,
@ -436,11 +436,12 @@ class TestTypeList(TestType):
class TestTypeSet(TestType):
project = identity_fakes.FakeProject.create_one_project()
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
methods={'set_keys': None})
volume_type = volume_fakes.create_one_volume_type(
methods={'set_keys': None},
)
def setUp(self):
super(TestTypeSet, self).setUp()
super().setUp()
self.types_mock.get.return_value = self.volume_type
@ -685,9 +686,9 @@ class TestTypeShow(TestType):
)
def setUp(self):
super(TestTypeShow, self).setUp()
super().setUp()
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
self.volume_type = volume_fakes.create_one_volume_type()
self.data = (
None,
self.volume_type.description,
@ -727,13 +728,20 @@ class TestTypeShow(TestType):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
private_type = volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'is_public': False})
type_access_list = volume_fakes.FakeTypeAccess.create_one_type_access()
with mock.patch.object(self.types_mock, 'get',
return_value=private_type):
with mock.patch.object(self.types_access_mock, 'list',
return_value=[type_access_list]):
private_type = volume_fakes.create_one_volume_type(
attrs={'is_public': False},
)
type_access_list = volume_fakes.create_one_type_access()
with mock.patch.object(
self.types_mock,
'get',
return_value=private_type,
):
with mock.patch.object(
self.types_access_mock,
'list',
return_value=[type_access_list],
):
columns, data = self.cmd.take_action(parsed_args)
self.types_mock.get.assert_called_once_with(
self.volume_type.id)
@ -760,8 +768,9 @@ class TestTypeShow(TestType):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
private_type = volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'is_public': False})
private_type = volume_fakes.create_one_volume_type(
attrs={'is_public': False},
)
with mock.patch.object(self.types_mock, 'get',
return_value=private_type):
with mock.patch.object(self.types_access_mock, 'list',
@ -784,16 +793,16 @@ class TestTypeShow(TestType):
self.assertCountEqual(private_type_data, data)
def test_type_show_with_encryption(self):
encryption_type = \
volume_fakes.FakeVolumeType.create_one_encryption_volume_type()
encryption_type = volume_fakes.create_one_encryption_volume_type()
encryption_info = {
'provider': 'LuksEncryptor',
'cipher': None,
'key_size': None,
'control_location': 'front-end',
}
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
attrs={'encryption': encryption_info})
self.volume_type = volume_fakes.create_one_volume_type(
attrs={'encryption': encryption_info},
)
self.types_mock.get.return_value = self.volume_type
self.encryption_types_mock.get.return_value = encryption_type
encryption_columns = (
@ -834,11 +843,12 @@ class TestTypeShow(TestType):
class TestTypeUnset(TestType):
project = identity_fakes.FakeProject.create_one_project()
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
methods={'unset_keys': None})
volume_type = volume_fakes.create_one_volume_type(
methods={'unset_keys': None},
)
def setUp(self):
super(TestTypeUnset, self).setUp()
super().setUp()
self.types_mock.get.return_value = self.volume_type
@ -936,7 +946,7 @@ class TestTypeUnset(TestType):
class TestColumns(TestType):
def test_encryption_info_column_with_info(self):
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
fake_volume_type = volume_fakes.create_one_volume_type()
type_id = fake_volume_type.id
encryption_info = {
@ -952,7 +962,7 @@ class TestColumns(TestType):
self.assertEqual(encryption_info, col.machine_readable())
def test_encryption_info_column_without_info(self):
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
fake_volume_type = volume_fakes.create_one_volume_type()
type_id = fake_volume_type.id
col = volume_type.EncryptionInfoColumn(type_id, {})

View File

@ -30,7 +30,7 @@ from openstackclient.volume.v2 import volume
class TestVolume(volume_fakes.TestVolume):
def setUp(self):
super(TestVolume, self).setUp()
super().setUp()
self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock.reset_mock()
@ -55,11 +55,9 @@ class TestVolume(volume_fakes.TestVolume):
self.consistencygroups_mock.reset_mock()
def setup_volumes_mock(self, count):
volumes = volume_fakes.FakeVolume.create_volumes(count=count)
volumes = volume_fakes.create_volumes(count=count)
self.volumes_mock.get = volume_fakes.FakeVolume.get_volumes(
volumes,
0)
self.volumes_mock.get = volume_fakes.get_volumes(volumes, 0)
return volumes
@ -83,9 +81,9 @@ class TestVolumeCreate(TestVolume):
)
def setUp(self):
super(TestVolumeCreate, self).setUp()
super().setUp()
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
self.new_volume = volume_fakes.create_one_volume()
self.volumes_mock.create.return_value = self.new_volume
self.datalist = (
@ -139,8 +137,7 @@ class TestVolumeCreate(TestVolume):
self.assertCountEqual(self.datalist, data)
def test_volume_create_options(self):
consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
consistency_group = volume_fakes.create_one_consistency_group()
self.consistencygroups_mock.get.return_value = consistency_group
arglist = [
'--size', str(self.new_volume.size),
@ -297,7 +294,7 @@ class TestVolumeCreate(TestVolume):
self.assertCountEqual(self.datalist, data)
def test_volume_create_with_snapshot(self):
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
snapshot = volume_fakes.create_one_snapshot()
self.new_volume.snapshot_id = snapshot.id
arglist = [
'--snapshot', self.new_volume.snapshot_id,
@ -504,7 +501,7 @@ class TestVolumeCreate(TestVolume):
class TestVolumeDelete(TestVolume):
def setUp(self):
super(TestVolumeDelete, self).setUp()
super().setUp()
self.volumes_mock.delete.return_value = None
@ -632,9 +629,9 @@ class TestVolumeList(TestVolume):
]
def setUp(self):
super(TestVolumeList, self).setUp()
super().setUp()
self.mock_volume = volume_fakes.FakeVolume.create_one_volume()
self.mock_volume = volume_fakes.create_one_volume()
self.volumes_mock.list.return_value = [self.mock_volume]
self.users_mock.get.return_value = self.user
@ -1107,10 +1104,10 @@ class TestVolumeList(TestVolume):
class TestVolumeMigrate(TestVolume):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
def setUp(self):
super(TestVolumeMigrate, self).setUp()
super().setUp()
self.volumes_mock.get.return_value = self._volume
self.volumes_mock.migrate_volume.return_value = None
@ -1173,12 +1170,12 @@ class TestVolumeMigrate(TestVolume):
class TestVolumeSet(TestVolume):
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
volume_type = volume_fakes.create_one_volume_type()
def setUp(self):
super(TestVolumeSet, self).setUp()
super().setUp()
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
self.new_volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = self.new_volume
self.types_mock.get.return_value = self.volume_type
@ -1427,9 +1424,9 @@ class TestVolumeSet(TestVolume):
class TestVolumeShow(TestVolume):
def setUp(self):
super(TestVolumeShow, self).setUp()
super().setUp()
self._volume = volume_fakes.FakeVolume.create_one_volume()
self._volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = self._volume
# Get the command object to test
self.cmd = volume.ShowVolume(self.app, None)
@ -1447,20 +1444,21 @@ class TestVolumeShow(TestVolume):
self.volumes_mock.get.assert_called_with(self._volume.id)
self.assertEqual(
volume_fakes.FakeVolume.get_volume_columns(self._volume),
columns)
volume_fakes.get_volume_columns(self._volume),
columns,
)
self.assertCountEqual(
volume_fakes.FakeVolume.get_volume_data(self._volume),
data)
volume_fakes.get_volume_data(self._volume),
data,
)
class TestVolumeUnset(TestVolume):
def setUp(self):
super(TestVolumeUnset, self).setUp()
super().setUp()
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
self.new_volume = volume_fakes.create_one_volume()
self.volumes_mock.get.return_value = self.new_volume
# Get the command object to set property
@ -1538,7 +1536,7 @@ class TestVolumeUnset(TestVolume):
class TestColumns(TestVolume):
def test_attachments_column_without_server_cache(self):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
server_id = _volume.attachments[0]['server_id']
device = _volume.attachments[0]['device']
@ -1548,7 +1546,7 @@ class TestColumns(TestVolume):
self.assertEqual(_volume.attachments, col.machine_readable())
def test_attachments_column_with_server_cache(self):
_volume = volume_fakes.FakeVolume.create_one_volume()
_volume = volume_fakes.create_one_volume()
server_id = _volume.attachments[0]['server_id']
device = _volume.attachments[0]['device']

View File

@ -20,10 +20,10 @@ class TestShowVolumeCapability(volume_fakes.TestVolume):
"""Test backend capability functionality."""
# The capability to be listed
capability = volume_fakes.FakeCapability.create_one_capability()
capability = volume_fakes.create_one_capability()
def setUp(self):
super(TestShowVolumeCapability, self).setUp()
super().setUp()
# Get a shortcut to the capability Mock
self.capability_mock = self.app.client_manager.volume.capabilities
@ -77,10 +77,10 @@ class TestListVolumePool(volume_fakes.TestVolume):
"""Tests for volume backend pool listing."""
# The pool to be listed
pools = volume_fakes.FakePool.create_one_pool()
pools = volume_fakes.create_one_pool()
def setUp(self):
super(TestListVolumePool, self).setUp()
super().setUp()
self.pool_mock = self.app.client_manager.volume.pools
self.pool_mock.list.return_value = [self.pools]

View File

@ -26,7 +26,7 @@ from openstackclient.volume.v2 import volume_backup
class TestBackup(volume_fakes.TestVolume):
def setUp(self):
super(TestBackup, self).setUp()
super().setUp()
self.backups_mock = self.app.client_manager.volume.backups
self.backups_mock.reset_mock()
@ -40,9 +40,9 @@ class TestBackup(volume_fakes.TestVolume):
class TestBackupCreate(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
new_backup = volume_fakes.FakeBackup.create_one_backup(
volume = volume_fakes.create_one_volume()
snapshot = volume_fakes.create_one_snapshot()
new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': volume.id, 'snapshot_id': snapshot.id})
columns = (
@ -71,7 +71,7 @@ class TestBackupCreate(TestBackup):
)
def setUp(self):
super(TestBackupCreate, self).setUp()
super().setUp()
self.volumes_mock.get.return_value = self.volume
self.snapshots_mock.get.return_value = self.snapshot
@ -242,13 +242,13 @@ class TestBackupCreate(TestBackup):
class TestBackupDelete(TestBackup):
backups = volume_fakes.FakeBackup.create_backups(count=2)
backups = volume_fakes.create_backups(count=2)
def setUp(self):
super(TestBackupDelete, self).setUp()
super().setUp()
self.backups_mock.get = (
volume_fakes.FakeBackup.get_backups(self.backups))
volume_fakes.get_backups(self.backups))
self.backups_mock.delete.return_value = None
# Get the command object to mock
@ -334,8 +334,8 @@ class TestBackupDelete(TestBackup):
class TestBackupList(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backups = volume_fakes.FakeBackup.create_backups(
volume = volume_fakes.create_one_volume()
backups = volume_fakes.create_backups(
attrs={'volume_id': volume.name}, count=3)
columns = (
@ -374,7 +374,7 @@ class TestBackupList(TestBackup):
))
def setUp(self):
super(TestBackupList, self).setUp()
super().setUp()
self.volumes_mock.list.return_value = [self.volume]
self.backups_mock.list.return_value = self.backups
@ -456,8 +456,8 @@ class TestBackupList(TestBackup):
class TestBackupRestore(TestBackup):
volume = volume_fakes.FakeVolume.create_one_volume()
backup = volume_fakes.FakeBackup.create_one_backup(
volume = volume_fakes.create_one_volume()
backup = volume_fakes.create_one_backup(
attrs={'volume_id': volume.id},
)
@ -467,7 +467,7 @@ class TestBackupRestore(TestBackup):
self.backups_mock.get.return_value = self.backup
self.volumes_mock.get.return_value = self.volume
self.restores_mock.restore.return_value = (
volume_fakes.FakeVolume.create_one_volume(
volume_fakes.create_one_volume(
{'id': self.volume['id']},
)
)
@ -550,12 +550,12 @@ class TestBackupRestore(TestBackup):
class TestBackupSet(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup(
backup = volume_fakes.create_one_backup(
attrs={'metadata': {'wow': 'cool'}},
)
def setUp(self):
super(TestBackupSet, self).setUp()
super().setUp()
self.backups_mock.get.return_value = self.backup
@ -784,7 +784,7 @@ class TestBackupSet(TestBackup):
class TestBackupUnset(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup(
backup = volume_fakes.create_one_backup(
attrs={'metadata': {'foo': 'bar'}},
)
@ -845,7 +845,7 @@ class TestBackupUnset(TestBackup):
class TestBackupShow(TestBackup):
backup = volume_fakes.FakeBackup.create_one_backup()
backup = volume_fakes.create_one_backup()
columns = (
'availability_zone',
@ -873,7 +873,7 @@ class TestBackupShow(TestBackup):
)
def setUp(self):
super(TestBackupShow, self).setUp()
super().setUp()
self.backups_mock.get.return_value = self.backup
# Get the command object to test

View File

@ -12,14 +12,14 @@
# under the License.
#
from openstackclient.tests.unit.volume.v2 import fakes as host_fakes
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.volume.v2 import volume_host
class TestVolumeHost(host_fakes.TestVolume):
class TestVolumeHost(volume_fakes.TestVolume):
def setUp(self):
super(TestVolumeHost, self).setUp()
super().setUp()
self.host_mock = self.app.client_manager.volume.services
self.host_mock.reset_mock()
@ -27,10 +27,10 @@ class TestVolumeHost(host_fakes.TestVolume):
class TestVolumeHostSet(TestVolumeHost):
service = host_fakes.FakeService.create_one_service()
service = volume_fakes.create_one_service()
def setUp(self):
super(TestVolumeHostSet, self).setUp()
super().setUp()
self.host_mock.freeze_host.return_value = None
self.host_mock.thaw_host.return_value = None
@ -89,10 +89,10 @@ class TestVolumeHostSet(TestVolumeHost):
class TestVolumeHostFailover(TestVolumeHost):
service = host_fakes.FakeService.create_one_service()
service = volume_fakes.create_one_service()
def setUp(self):
super(TestVolumeHostFailover, self).setUp()
super().setUp()
self.host_mock.failover_host.return_value = None

View File

@ -54,8 +54,8 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
def setUp(self):
super().setUp()
self.volume = volume_fakes.FakeVolume.create_one_volume()
self.new_snapshot = volume_fakes.FakeSnapshot.create_one_snapshot(
self.volume = volume_fakes.create_one_volume()
self.new_snapshot = volume_fakes.create_one_snapshot(
attrs={'volume_id': self.volume.id})
self.data = (
@ -179,13 +179,13 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
class TestVolumeSnapshotDelete(TestVolumeSnapshot):
snapshots = volume_fakes.FakeSnapshot.create_snapshots(count=2)
snapshots = volume_fakes.create_snapshots(count=2)
def setUp(self):
super().setUp()
self.snapshots_mock.get = (
volume_fakes.FakeSnapshot.get_snapshots(self.snapshots))
volume_fakes.get_snapshots(self.snapshots))
self.snapshots_mock.delete.return_value = None
# Get the command object to mock
@ -273,9 +273,9 @@ class TestVolumeSnapshotDelete(TestVolumeSnapshot):
class TestVolumeSnapshotList(TestVolumeSnapshot):
volume = volume_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
project = project_fakes.FakeProject.create_one_project()
snapshots = volume_fakes.FakeSnapshot.create_snapshots(
snapshots = volume_fakes.create_snapshots(
attrs={'volume_id': volume.name}, count=3)
columns = [
@ -495,7 +495,7 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
class TestVolumeSnapshotSet(TestVolumeSnapshot):
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
snapshot = volume_fakes.create_one_snapshot()
def setUp(self):
super().setUp()
@ -677,7 +677,7 @@ class TestVolumeSnapshotShow(TestVolumeSnapshot):
def setUp(self):
super().setUp()
self.snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
self.snapshot = volume_fakes.create_one_snapshot()
self.data = (
self.snapshot.created_at,
@ -712,7 +712,7 @@ class TestVolumeSnapshotShow(TestVolumeSnapshot):
class TestVolumeSnapshotUnset(TestVolumeSnapshot):
snapshot = volume_fakes.FakeSnapshot.create_one_snapshot()
snapshot = volume_fakes.create_one_snapshot()
def setUp(self):
super().setUp()

View File

@ -20,14 +20,14 @@ from osc_lib import exceptions
from osc_lib import utils
from openstackclient.tests.unit import utils as test_utils
from openstackclient.tests.unit.volume.v2 import fakes as transfer_fakes
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
from openstackclient.volume.v2 import volume_transfer_request
class TestTransfer(transfer_fakes.TestVolume):
class TestTransfer(volume_fakes.TestVolume):
def setUp(self):
super(TestTransfer, self).setUp()
super().setUp()
# Get a shortcut to the TransferManager Mock
self.transfer_mock = self.app.client_manager.volume.transfers
@ -47,10 +47,9 @@ class TestTransferAccept(TestTransfer):
)
def setUp(self):
super(TestTransferAccept, self).setUp()
super().setUp()
self.volume_transfer = (
transfer_fakes.FakeTransfer.create_one_transfer())
self.volume_transfer = volume_fakes.create_one_transfer()
self.data = (
self.volume_transfer.id,
self.volume_transfer.name,
@ -106,7 +105,7 @@ class TestTransferAccept(TestTransfer):
class TestTransferCreate(TestTransfer):
volume = transfer_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
columns = (
'auth_key',
@ -117,12 +116,14 @@ class TestTransferCreate(TestTransfer):
)
def setUp(self):
super(TestTransferCreate, self).setUp()
super().setUp()
self.volume_transfer = transfer_fakes.FakeTransfer.create_one_transfer(
attrs={'volume_id': self.volume.id,
'auth_key': 'key',
'created_at': 'time'}
self.volume_transfer = volume_fakes.create_one_transfer(
attrs={
'volume_id': self.volume.id,
'auth_key': 'key',
'created_at': 'time',
},
)
self.data = (
self.volume_transfer.auth_key,
@ -221,13 +222,14 @@ class TestTransferCreate(TestTransfer):
class TestTransferDelete(TestTransfer):
volume_transfers = transfer_fakes.FakeTransfer.create_transfers(count=2)
volume_transfers = volume_fakes.create_transfers(count=2)
def setUp(self):
super(TestTransferDelete, self).setUp()
super().setUp()
self.transfer_mock.get = (
transfer_fakes.FakeTransfer.get_transfers(self.volume_transfers))
self.transfer_mock.get = volume_fakes.get_transfers(
self.volume_transfers,
)
self.transfer_mock.delete.return_value = None
# Get the command object to mock
@ -300,10 +302,10 @@ class TestTransferDelete(TestTransfer):
class TestTransferList(TestTransfer):
# The Transfers to be listed
volume_transfers = transfer_fakes.FakeTransfer.create_one_transfer()
volume_transfers = volume_fakes.create_one_transfer()
def setUp(self):
super(TestTransferList, self).setUp()
super().setUp()
self.transfer_mock.list.return_value = [self.volume_transfers]
@ -394,11 +396,10 @@ class TestTransferShow(TestTransfer):
)
def setUp(self):
super(TestTransferShow, self).setUp()
super().setUp()
self.volume_transfer = (
transfer_fakes.FakeTransfer.create_one_transfer(
attrs={'created_at': 'time'})
self.volume_transfer = volume_fakes.create_one_transfer(
attrs={'created_at': 'time'},
)
self.data = (
self.volume_transfer.created_at,

View File

@ -24,7 +24,6 @@ from openstackclient.tests.unit.volume.v2 import fakes as volume_v2_fakes
class FakeVolumeClient:
def __init__(self, **kwargs):
self.auth_token = kwargs['token']
self.management_url = kwargs['endpoint']
@ -51,17 +50,14 @@ class FakeVolumeClient:
class TestVolume(utils.TestCommand):
def setUp(self):
super().setUp()
self.app.client_manager.volume = FakeVolumeClient(
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
)
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
)
self.app.client_manager.compute = compute_fakes.FakeComputev2Client(
endpoint=fakes.AUTH_URL,
@ -70,353 +66,309 @@ class TestVolume(utils.TestCommand):
# TODO(stephenfin): Check if the responses are actually the same
FakeVolume = volume_v2_fakes.FakeVolume
FakeVolumeType = volume_v2_fakes.FakeVolumeType
create_one_volume = volume_v2_fakes.create_one_volume
create_one_volume_type = volume_v2_fakes.create_one_volume_type
class FakeCluster:
"""Fake one or more clusters."""
def create_one_cluster(attrs=None):
"""Create a fake service cluster.
@staticmethod
def create_one_cluster(attrs=None):
"""Create a fake service cluster.
:param attrs: A dictionary with all attributes of service cluster
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
:param attrs: A dictionary with all attributes of service cluster
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
# Set default attribute
cluster_info = {
'name': f'cluster-{uuid.uuid4().hex}',
'binary': f'binary-{uuid.uuid4().hex}',
'state': random.choice(['up', 'down']),
'status': random.choice(['enabled', 'disabled']),
'disabled_reason': None,
'num_hosts': random.randint(1, 64),
'num_down_hosts': random.randint(1, 64),
'last_heartbeat': '2015-09-16T09:28:52.000000',
'created_at': '2015-09-16T09:28:52.000000',
'updated_at': '2015-09-16T09:28:52.000000',
'replication_status': None,
'frozen': False,
'active_backend_id': None,
}
# Set default attribute
cluster_info = {
'name': f'cluster-{uuid.uuid4().hex}',
'binary': f'binary-{uuid.uuid4().hex}',
'state': random.choice(['up', 'down']),
'status': random.choice(['enabled', 'disabled']),
'disabled_reason': None,
'num_hosts': random.randint(1, 64),
'num_down_hosts': random.randint(1, 64),
'last_heartbeat': '2015-09-16T09:28:52.000000',
'created_at': '2015-09-16T09:28:52.000000',
'updated_at': '2015-09-16T09:28:52.000000',
'replication_status': None,
'frozen': False,
'active_backend_id': None,
}
# Overwrite default attributes if there are some attributes set
cluster_info.update(attrs)
# Overwrite default attributes if there are some attributes set
cluster_info.update(attrs)
return fakes.FakeResource(
None,
cluster_info,
loaded=True)
@staticmethod
def create_clusters(attrs=None, count=2):
"""Create multiple fake service clusters.
:param attrs: A dictionary with all attributes of service cluster
:param count: The number of service clusters to be faked
:return: A list of FakeResource objects
"""
clusters = []
for n in range(0, count):
clusters.append(FakeCluster.create_one_cluster(attrs))
return clusters
return fakes.FakeResource(None, cluster_info, loaded=True)
class FakeResourceFilter:
"""Fake one or more resource filters."""
def create_clusters(attrs=None, count=2):
"""Create multiple fake service clusters.
@staticmethod
def create_one_resource_filter(attrs=None):
"""Create a fake resource filter.
:param attrs: A dictionary with all attributes of service cluster
:param count: The number of service clusters to be faked
:return: A list of FakeResource objects
"""
clusters = []
for n in range(0, count):
clusters.append(create_one_cluster(attrs))
:param attrs: A dictionary with all attributes of resource filter
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
# Set default attribute
resource_filter_info = {
'filters': [
'name',
'status',
'image_metadata',
'bootable',
'migration_status',
],
'resource': 'volume',
}
# Overwrite default attributes if there are some attributes set
resource_filter_info.update(attrs)
return fakes.FakeResource(None, resource_filter_info, loaded=True)
@staticmethod
def create_resource_filters(attrs=None, count=2):
"""Create multiple fake resource filters.
:param attrs: A dictionary with all attributes of resource filter
:param count: The number of resource filters to be faked
:return: A list of FakeResource objects
"""
resource_filters = []
for n in range(0, count):
resource_filters.append(
FakeResourceFilter.create_one_resource_filter(attrs)
)
return resource_filters
return clusters
class FakeVolumeGroup:
"""Fake one or more volume groups."""
def create_one_resource_filter(attrs=None):
"""Create a fake resource filter.
@staticmethod
def create_one_volume_group(attrs=None):
"""Create a fake group.
:param attrs: A dictionary with all attributes of resource filter
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
:param attrs: A dictionary with all attributes of group
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
# Set default attribute
group_type = attrs.pop('group_type', None) or uuid.uuid4().hex
volume_types = attrs.pop('volume_types', None) or [uuid.uuid4().hex]
resource_filter_info = {
'filters': [
'name',
'status',
'image_metadata',
'bootable',
'migration_status',
],
'resource': 'volume',
}
# Set default attribute
group_info = {
'id': uuid.uuid4().hex,
'status': random.choice([
# Overwrite default attributes if there are some attributes set
resource_filter_info.update(attrs)
return fakes.FakeResource(None, resource_filter_info, loaded=True)
def create_resource_filters(attrs=None, count=2):
"""Create multiple fake resource filters.
:param attrs: A dictionary with all attributes of resource filter
:param count: The number of resource filters to be faked
:return: A list of FakeResource objects
"""
resource_filters = []
for n in range(0, count):
resource_filters.append(create_one_resource_filter(attrs))
return resource_filters
def create_one_volume_group(attrs=None):
"""Create a fake group.
:param attrs: A dictionary with all attributes of group
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
group_type = attrs.pop('group_type', None) or uuid.uuid4().hex
volume_types = attrs.pop('volume_types', None) or [uuid.uuid4().hex]
# Set default attribute
group_info = {
'id': uuid.uuid4().hex,
'status': random.choice(
[
'available',
]),
'availability_zone': f'az-{uuid.uuid4().hex}',
'created_at': '2015-09-16T09:28:52.000000',
'name': 'first_group',
'description': f'description-{uuid.uuid4().hex}',
'group_type': group_type,
'volume_types': volume_types,
'volumes': [f'volume-{uuid.uuid4().hex}'],
'group_snapshot_id': None,
'source_group_id': None,
'project_id': f'project-{uuid.uuid4().hex}',
}
]
),
'availability_zone': f'az-{uuid.uuid4().hex}',
'created_at': '2015-09-16T09:28:52.000000',
'name': 'first_group',
'description': f'description-{uuid.uuid4().hex}',
'group_type': group_type,
'volume_types': volume_types,
'volumes': [f'volume-{uuid.uuid4().hex}'],
'group_snapshot_id': None,
'source_group_id': None,
'project_id': f'project-{uuid.uuid4().hex}',
}
# Overwrite default attributes if there are some attributes set
group_info.update(attrs)
# Overwrite default attributes if there are some attributes set
group_info.update(attrs)
group = fakes.FakeResource(
None,
group_info,
loaded=True)
return group
@staticmethod
def create_volume_groups(attrs=None, count=2):
"""Create multiple fake groups.
:param attrs: A dictionary with all attributes of group
:param count: The number of groups to be faked
:return: A list of FakeResource objects
"""
groups = []
for n in range(0, count):
groups.append(FakeVolumeGroup.create_one_volume_group(attrs))
return groups
group = fakes.FakeResource(None, group_info, loaded=True)
return group
class FakeVolumeGroupSnapshot:
"""Fake one or more volume group snapshots."""
def create_volume_groups(attrs=None, count=2):
"""Create multiple fake groups.
@staticmethod
def create_one_volume_group_snapshot(attrs=None, methods=None):
"""Create a fake group snapshot.
:param attrs: A dictionary with all attributes of group
:param count: The number of groups to be faked
:return: A list of FakeResource objects
"""
groups = []
for n in range(0, count):
groups.append(create_one_volume_group(attrs))
:param attrs: A dictionary with all attributes
:param methods: A dictionary with all methods
:return: A FakeResource object with id, name, description, etc.
"""
attrs = attrs or {}
# Set default attribute
group_snapshot_info = {
'id': uuid.uuid4().hex,
'name': f'group-snapshot-{uuid.uuid4().hex}',
'description': f'description-{uuid.uuid4().hex}',
'status': random.choice(['available']),
'group_id': uuid.uuid4().hex,
'group_type_id': uuid.uuid4().hex,
'project_id': uuid.uuid4().hex,
}
# Overwrite default attributes if there are some attributes set
group_snapshot_info.update(attrs)
group_snapshot = fakes.FakeResource(
None,
group_snapshot_info,
methods=methods,
loaded=True)
return group_snapshot
@staticmethod
def create_volume_group_snapshots(attrs=None, count=2):
"""Create multiple fake group snapshots.
:param attrs: A dictionary with all attributes of group snapshot
:param count: The number of group snapshots to be faked
:return: A list of FakeResource objects
"""
group_snapshots = []
for n in range(0, count):
group_snapshots.append(
FakeVolumeGroupSnapshot.create_one_volume_group_snapshot(attrs)
)
return group_snapshots
return groups
class FakeVolumeGroupType:
"""Fake one or more volume group types."""
def create_one_volume_group_snapshot(attrs=None, methods=None):
"""Create a fake group snapshot.
@staticmethod
def create_one_volume_group_type(attrs=None, methods=None):
"""Create a fake group type.
:param attrs: A dictionary with all attributes
:param methods: A dictionary with all methods
:return: A FakeResource object with id, name, description, etc.
"""
attrs = attrs or {}
:param attrs: A dictionary with all attributes of group type
:param methods: A dictionary with all methods
:return: A FakeResource object with id, name, description, etc.
"""
attrs = attrs or {}
# Set default attribute
group_snapshot_info = {
'id': uuid.uuid4().hex,
'name': f'group-snapshot-{uuid.uuid4().hex}',
'description': f'description-{uuid.uuid4().hex}',
'status': random.choice(['available']),
'group_id': uuid.uuid4().hex,
'group_type_id': uuid.uuid4().hex,
'project_id': uuid.uuid4().hex,
}
# Set default attribute
group_type_info = {
'id': uuid.uuid4().hex,
'name': f'group-type-{uuid.uuid4().hex}',
'description': f'description-{uuid.uuid4().hex}',
'is_public': random.choice([True, False]),
'group_specs': {},
}
# Overwrite default attributes if there are some attributes set
group_snapshot_info.update(attrs)
# Overwrite default attributes if there are some attributes set
group_type_info.update(attrs)
group_type = fakes.FakeResource(
None,
group_type_info,
methods=methods,
loaded=True)
return group_type
@staticmethod
def create_volume_group_types(attrs=None, count=2):
"""Create multiple fake group types.
:param attrs: A dictionary with all attributes of group type
:param count: The number of group types to be faked
:return: A list of FakeResource objects
"""
group_types = []
for n in range(0, count):
group_types.append(
FakeVolumeGroupType.create_one_volume_group_type(attrs)
)
return group_types
group_snapshot = fakes.FakeResource(
None, group_snapshot_info, methods=methods, loaded=True
)
return group_snapshot
class FakeVolumeMessage:
"""Fake one or more volume messages."""
def create_volume_group_snapshots(attrs=None, count=2):
"""Create multiple fake group snapshots.
@staticmethod
def create_one_volume_message(attrs=None):
"""Create a fake message.
:param attrs: A dictionary with all attributes of group snapshot
:param count: The number of group snapshots to be faked
:return: A list of FakeResource objects
"""
group_snapshots = []
for n in range(0, count):
group_snapshots.append(create_one_volume_group_snapshot(attrs))
:param attrs: A dictionary with all attributes of message
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
# Set default attribute
message_info = {
'created_at': '2016-02-11T11:17:37.000000',
'event_id': f'VOLUME_{random.randint(1, 999999):06d}',
'guaranteed_until': '2016-02-11T11:17:37.000000',
'id': uuid.uuid4().hex,
'message_level': 'ERROR',
'request_id': f'req-{uuid.uuid4().hex}',
'resource_type': 'VOLUME',
'resource_uuid': uuid.uuid4().hex,
'user_message': f'message-{uuid.uuid4().hex}',
}
# Overwrite default attributes if there are some attributes set
message_info.update(attrs)
return fakes.FakeResource(
None,
message_info,
loaded=True)
@staticmethod
def create_volume_messages(attrs=None, count=2):
"""Create multiple fake messages.
:param attrs: A dictionary with all attributes of message
:param count: The number of messages to be faked
:return: A list of FakeResource objects
"""
messages = []
for n in range(0, count):
messages.append(FakeVolumeMessage.create_one_volume_message(attrs))
return messages
@staticmethod
def get_volume_messages(messages=None, count=2):
"""Get an iterable MagicMock object with a list of faked messages.
If messages list is provided, then initialize the Mock object with the
list. Otherwise create one.
:param messages: A list of FakeResource objects faking messages
:param count: The number of messages to be faked
:return An iterable Mock object with side_effect set to a list of faked
messages
"""
if messages is None:
messages = FakeVolumeMessage.create_messages(count)
return mock.Mock(side_effect=messages)
return group_snapshots
class FakeVolumeAttachment:
"""Fake one or more volume attachments."""
def create_one_volume_group_type(attrs=None, methods=None):
"""Create a fake group type.
@staticmethod
def create_one_volume_attachment(attrs=None):
"""Create a fake volume attachment.
:param attrs: A dictionary with all attributes of group type
:param methods: A dictionary with all methods
:return: A FakeResource object with id, name, description, etc.
"""
attrs = attrs or {}
:param attrs: A dictionary with all attributes of volume attachment
:return: A FakeResource object with id, status, etc.
"""
attrs = attrs or {}
# Set default attribute
group_type_info = {
'id': uuid.uuid4().hex,
'name': f'group-type-{uuid.uuid4().hex}',
'description': f'description-{uuid.uuid4().hex}',
'is_public': random.choice([True, False]),
'group_specs': {},
}
attachment_id = uuid.uuid4().hex
volume_id = attrs.pop('volume_id', None) or uuid.uuid4().hex
server_id = attrs.pop('instance', None) or uuid.uuid4().hex
# Overwrite default attributes if there are some attributes set
group_type_info.update(attrs)
# Set default attribute
attachment_info = {
'id': attachment_id,
'volume_id': volume_id,
'instance': server_id,
'status': random.choice([
group_type = fakes.FakeResource(
None, group_type_info, methods=methods, loaded=True
)
return group_type
def create_volume_group_types(attrs=None, count=2):
"""Create multiple fake group types.
:param attrs: A dictionary with all attributes of group type
:param count: The number of group types to be faked
:return: A list of FakeResource objects
"""
group_types = []
for n in range(0, count):
group_types.append(create_one_volume_group_type(attrs))
return group_types
def create_one_volume_message(attrs=None):
"""Create a fake message.
:param attrs: A dictionary with all attributes of message
:return: A FakeResource object with id, name, status, etc.
"""
attrs = attrs or {}
# Set default attribute
message_info = {
'created_at': '2016-02-11T11:17:37.000000',
'event_id': f'VOLUME_{random.randint(1, 999999):06d}',
'guaranteed_until': '2016-02-11T11:17:37.000000',
'id': uuid.uuid4().hex,
'message_level': 'ERROR',
'request_id': f'req-{uuid.uuid4().hex}',
'resource_type': 'VOLUME',
'resource_uuid': uuid.uuid4().hex,
'user_message': f'message-{uuid.uuid4().hex}',
}
# Overwrite default attributes if there are some attributes set
message_info.update(attrs)
return fakes.FakeResource(None, message_info, loaded=True)
def create_volume_messages(attrs=None, count=2):
"""Create multiple fake messages.
:param attrs: A dictionary with all attributes of message
:param count: The number of messages to be faked
:return: A list of FakeResource objects
"""
messages = []
for n in range(0, count):
messages.append(create_one_volume_message(attrs))
return messages
def get_volume_messages(messages=None, count=2):
"""Get an iterable MagicMock object with a list of faked messages.
If messages list is provided, then initialize the Mock object with the
list. Otherwise create one.
:param messages: A list of FakeResource objects faking messages
:param count: The number of messages to be faked
:return An iterable Mock object with side_effect set to a list of faked
messages
"""
if messages is None:
messages = create_volume_messages(count)
return mock.Mock(side_effect=messages)
def create_one_volume_attachment(attrs=None):
"""Create a fake volume attachment.
:param attrs: A dictionary with all attributes of volume attachment
:return: A FakeResource object with id, status, etc.
"""
attrs = attrs or {}
attachment_id = uuid.uuid4().hex
volume_id = attrs.pop('volume_id', None) or uuid.uuid4().hex
server_id = attrs.pop('instance', None) or uuid.uuid4().hex
# Set default attribute
attachment_info = {
'id': attachment_id,
'volume_id': volume_id,
'instance': server_id,
'status': random.choice(
[
'attached',
'attaching',
'detached',
@ -424,67 +376,63 @@ class FakeVolumeAttachment:
'error_attaching',
'error_detaching',
'deleted',
]),
'attach_mode': random.choice(['ro', 'rw']),
'attached_at': '2015-09-16T09:28:52.000000',
'detached_at': None,
'connection_info': {
'access_mode': 'rw',
'attachment_id': attachment_id,
'auth_method': 'CHAP',
'auth_password': 'AcUZ8PpxLHwzypMC',
'auth_username': '7j3EZQWT3rbE6pcSGKvK',
'cacheable': False,
'driver_volume_type': 'iscsi',
'encrypted': False,
'qos_specs': None,
'target_discovered': False,
'target_iqn':
f'iqn.2010-10.org.openstack:volume-{attachment_id}',
'target_lun': '1',
'target_portal': '192.168.122.170:3260',
'volume_id': volume_id,
},
}
]
),
'attach_mode': random.choice(['ro', 'rw']),
'attached_at': '2015-09-16T09:28:52.000000',
'detached_at': None,
'connection_info': {
'access_mode': 'rw',
'attachment_id': attachment_id,
'auth_method': 'CHAP',
'auth_password': 'AcUZ8PpxLHwzypMC',
'auth_username': '7j3EZQWT3rbE6pcSGKvK',
'cacheable': False,
'driver_volume_type': 'iscsi',
'encrypted': False,
'qos_specs': None,
'target_discovered': False,
'target_iqn': f'iqn.2010-10.org.openstack:volume-{attachment_id}',
'target_lun': '1',
'target_portal': '192.168.122.170:3260',
'volume_id': volume_id,
},
}
# Overwrite default attributes if there are some attributes set
attachment_info.update(attrs)
# Overwrite default attributes if there are some attributes set
attachment_info.update(attrs)
return fakes.FakeResource(
None,
attachment_info,
loaded=True)
return fakes.FakeResource(None, attachment_info, loaded=True)
@staticmethod
def create_volume_attachments(attrs=None, count=2):
"""Create multiple fake volume attachments.
:param attrs: A dictionary with all attributes of volume attachment
:param count: The number of volume attachments to be faked
:return: A list of FakeResource objects
"""
attachments = []
def create_volume_attachments(attrs=None, count=2):
"""Create multiple fake volume attachments.
for n in range(0, count):
attachments.append(
FakeVolumeAttachment.create_one_volume_attachment(attrs))
:param attrs: A dictionary with all attributes of volume attachment
:param count: The number of volume attachments to be faked
:return: A list of FakeResource objects
"""
attachments = []
return attachments
for n in range(0, count):
attachments.append(create_one_volume_attachment(attrs))
@staticmethod
def get_volume_attachments(attachments=None, count=2):
"""Get an iterable MagicMock object with a list of faked volumes.
return attachments
If attachments list is provided, then initialize the Mock object with
the list. Otherwise create one.
:param attachments: A list of FakeResource objects faking volume
attachments
:param count: The number of volume attachments to be faked
:return An iterable Mock object with side_effect set to a list of faked
volume attachments
"""
if attachments is None:
attachments = FakeVolumeAttachment.create_volume_attachments(count)
def get_volume_attachments(attachments=None, count=2):
"""Get an iterable MagicMock object with a list of faked volumes.
return mock.Mock(side_effect=attachments)
If attachments list is provided, then initialize the Mock object with
the list. Otherwise create one.
:param attachments: A list of FakeResource objects faking volume
attachments
:param count: The number of volume attachments to be faked
:return An iterable Mock object with side_effect set to a list of faked
volume attachments
"""
if attachments is None:
attachments = create_volume_attachments(count)
return mock.Mock(side_effect=attachments)

View File

@ -30,7 +30,7 @@ class TestBlockStorageCluster(volume_fakes.TestVolume):
class TestBlockStorageClusterList(TestBlockStorageCluster):
# The cluster to be listed
fake_clusters = volume_fakes.FakeCluster.create_clusters()
fake_clusters = volume_fakes.create_clusters()
def setUp(self):
super().setUp()
@ -176,7 +176,7 @@ class TestBlockStorageClusterList(TestBlockStorageCluster):
class TestBlockStorageClusterSet(TestBlockStorageCluster):
cluster = volume_fakes.FakeCluster.create_one_cluster()
cluster = volume_fakes.create_one_cluster()
columns = (
'Name',
'Binary',
@ -347,7 +347,7 @@ class TestBlockStorageClusterSet(TestBlockStorageCluster):
class TestBlockStorageClusterShow(TestBlockStorageCluster):
cluster = volume_fakes.FakeCluster.create_one_cluster()
cluster = volume_fakes.create_one_cluster()
columns = (
'Name',
'Binary',

View File

@ -31,8 +31,7 @@ class TestBlockStorageResourceFilter(volume_fakes.TestVolume):
class TestBlockStorageResourceFilterList(TestBlockStorageResourceFilter):
# The resource filters to be listed
fake_resource_filters = \
volume_fakes.FakeResourceFilter.create_resource_filters()
fake_resource_filters = volume_fakes.create_resource_filters()
def setUp(self):
super().setUp()
@ -86,8 +85,7 @@ class TestBlockStorageResourceFilterList(TestBlockStorageResourceFilter):
class TestBlockStorageResourceFilterShow(TestBlockStorageResourceFilter):
# The resource filters to be listed
fake_resource_filter = \
volume_fakes.FakeResourceFilter.create_one_resource_filter()
fake_resource_filter = volume_fakes.create_one_resource_filter()
def setUp(self):
super().setUp()

View File

@ -41,11 +41,11 @@ class TestVolumeAttachment(volume_fakes.TestVolume):
class TestVolumeAttachmentCreate(TestVolumeAttachment):
volume = volume_fakes.FakeVolume.create_one_volume()
volume = volume_fakes.create_one_volume()
server = compute_fakes.FakeServer.create_one_server()
volume_attachment = \
volume_fakes.FakeVolumeAttachment.create_one_volume_attachment(
attrs={'instance': server.id, 'volume_id': volume.id})
volume_attachment = volume_fakes.create_one_volume_attachment(
attrs={'instance': server.id, 'volume_id': volume.id},
)
columns = (
'ID',
@ -238,8 +238,7 @@ class TestVolumeAttachmentCreate(TestVolumeAttachment):
class TestVolumeAttachmentDelete(TestVolumeAttachment):
volume_attachment = \
volume_fakes.FakeVolumeAttachment.create_one_volume_attachment()
volume_attachment = volume_fakes.create_one_volume_attachment()
def setUp(self):
super().setUp()
@ -290,8 +289,7 @@ class TestVolumeAttachmentDelete(TestVolumeAttachment):
class TestVolumeAttachmentSet(TestVolumeAttachment):
volume_attachment = \
volume_fakes.FakeVolumeAttachment.create_one_volume_attachment()
volume_attachment = volume_fakes.create_one_volume_attachment()
columns = (
'ID',
@ -391,8 +389,7 @@ class TestVolumeAttachmentSet(TestVolumeAttachment):
class TestVolumeAttachmentComplete(TestVolumeAttachment):
volume_attachment = \
volume_fakes.FakeVolumeAttachment.create_one_volume_attachment()
volume_attachment = volume_fakes.create_one_volume_attachment()
def setUp(self):
super().setUp()
@ -444,8 +441,7 @@ class TestVolumeAttachmentComplete(TestVolumeAttachment):
class TestVolumeAttachmentList(TestVolumeAttachment):
project = identity_fakes.FakeProject.create_one_project()
volume_attachments = \
volume_fakes.FakeVolumeAttachment.create_volume_attachments()
volume_attachments = volume_fakes.create_volume_attachments()
columns = (
'ID',

View File

@ -35,10 +35,9 @@ class TestVolumeGroup(volume_fakes.TestVolume):
class TestVolumeGroupCreate(TestVolumeGroup):
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
fake_volume_group_type = \
volume_fakes.FakeVolumeGroupType.create_one_volume_group_type()
fake_volume_group = volume_fakes.FakeVolumeGroup.create_one_volume_group(
fake_volume_type = volume_fakes.create_one_volume_type()
fake_volume_group_type = volume_fakes.create_one_volume_group_type()
fake_volume_group = volume_fakes.create_one_volume_group(
attrs={
'group_type': fake_volume_group_type.id,
'volume_types': [fake_volume_type.id],
@ -180,8 +179,7 @@ class TestVolumeGroupCreate(TestVolumeGroup):
class TestVolumeGroupDelete(TestVolumeGroup):
fake_volume_group = \
volume_fakes.FakeVolumeGroup.create_one_volume_group()
fake_volume_group = volume_fakes.create_one_volume_group()
def setUp(self):
super().setUp()
@ -236,8 +234,7 @@ class TestVolumeGroupDelete(TestVolumeGroup):
class TestVolumeGroupSet(TestVolumeGroup):
fake_volume_group = \
volume_fakes.FakeVolumeGroup.create_one_volume_group()
fake_volume_group = volume_fakes.create_one_volume_group()
columns = (
'ID',
@ -368,8 +365,7 @@ class TestVolumeGroupSet(TestVolumeGroup):
class TestVolumeGroupList(TestVolumeGroup):
fake_volume_groups = \
volume_fakes.FakeVolumeGroup.create_volume_groups()
fake_volume_groups = volume_fakes.create_volume_groups()
columns = (
'ID',
@ -436,8 +432,7 @@ class TestVolumeGroupList(TestVolumeGroup):
class TestVolumeGroupFailover(TestVolumeGroup):
fake_volume_group = \
volume_fakes.FakeVolumeGroup.create_one_volume_group()
fake_volume_group = volume_fakes.create_one_volume_group()
def setUp(self):
super().setUp()

View File

@ -32,9 +32,9 @@ class TestVolumeGroupSnapshot(volume_fakes.TestVolume):
class TestVolumeGroupSnapshotCreate(TestVolumeGroupSnapshot):
fake_volume_group = volume_fakes.FakeVolumeGroup.create_one_volume_group()
fake_volume_group = volume_fakes.create_one_volume_group()
fake_volume_group_snapshot = \
volume_fakes.FakeVolumeGroupSnapshot.create_one_volume_group_snapshot()
volume_fakes.create_one_volume_group_snapshot()
columns = (
'ID',
@ -141,7 +141,7 @@ class TestVolumeGroupSnapshotCreate(TestVolumeGroupSnapshot):
class TestVolumeGroupSnapshotDelete(TestVolumeGroupSnapshot):
fake_volume_group_snapshot = \
volume_fakes.FakeVolumeGroupSnapshot.create_one_volume_group_snapshot()
volume_fakes.create_one_volume_group_snapshot()
def setUp(self):
super().setUp()
@ -195,8 +195,7 @@ class TestVolumeGroupSnapshotDelete(TestVolumeGroupSnapshot):
class TestVolumeGroupSnapshotList(TestVolumeGroupSnapshot):
fake_volume_group_snapshots = \
volume_fakes.FakeVolumeGroupSnapshot.create_volume_group_snapshots()
fake_volume_group_snapshots = volume_fakes.create_volume_group_snapshots()
columns = (
'ID',

View File

@ -34,8 +34,7 @@ class TestVolumeGroupTypeCreate(TestVolumeGroupType):
maxDiff = 2000
fake_volume_group_type = \
volume_fakes.FakeVolumeGroupType.create_one_volume_group_type()
fake_volume_group_type = volume_fakes.create_one_volume_group_type()
columns = (
'ID',
@ -133,8 +132,7 @@ class TestVolumeGroupTypeCreate(TestVolumeGroupType):
class TestVolumeGroupTypeDelete(TestVolumeGroupType):
fake_volume_group_type = \
volume_fakes.FakeVolumeGroupType.create_one_volume_group_type()
fake_volume_group_type = volume_fakes.create_one_volume_group_type()
def setUp(self):
super().setUp()
@ -187,13 +185,13 @@ class TestVolumeGroupTypeDelete(TestVolumeGroupType):
class TestVolumeGroupTypeSet(TestVolumeGroupType):
fake_volume_group_type = \
volume_fakes.FakeVolumeGroupType.create_one_volume_group_type(
methods={
'get_keys': {'foo': 'bar'},
'set_keys': None,
'unset_keys': None,
})
fake_volume_group_type = volume_fakes.create_one_volume_group_type(
methods={
'get_keys': {'foo': 'bar'},
'set_keys': None,
'unset_keys': None,
},
)
columns = (
'ID',
@ -316,9 +314,9 @@ class TestVolumeGroupTypeSet(TestVolumeGroupType):
class TestVolumeGroupTypeUnset(TestVolumeGroupType):
fake_volume_group_type = \
volume_fakes.FakeVolumeGroupType.create_one_volume_group_type(
methods={'unset_keys': None})
fake_volume_group_type = volume_fakes.create_one_volume_group_type(
methods={'unset_keys': None},
)
columns = (
'ID',
@ -393,8 +391,7 @@ class TestVolumeGroupTypeUnset(TestVolumeGroupType):
class TestVolumeGroupTypeList(TestVolumeGroupType):
fake_volume_group_types = \
volume_fakes.FakeVolumeGroupType.create_volume_group_types()
fake_volume_group_types = volume_fakes.create_volume_group_types()
columns = (
'ID',

View File

@ -34,15 +34,14 @@ class TestVolumeMessage(volume_fakes.TestVolume):
class TestVolumeMessageDelete(TestVolumeMessage):
fake_messages = volume_fakes.FakeVolumeMessage.create_volume_messages(
count=2)
fake_messages = volume_fakes.create_volume_messages(count=2)
def setUp(self):
super().setUp()
self.volume_messages_mock.get = \
volume_fakes.FakeVolumeMessage.get_volume_messages(
self.fake_messages)
self.volume_messages_mock.get = volume_fakes.get_volume_messages(
self.fake_messages,
)
self.volume_messages_mock.delete.return_value = None
# Get the command object to mock
@ -139,8 +138,7 @@ class TestVolumeMessageDelete(TestVolumeMessage):
class TestVolumeMessageList(TestVolumeMessage):
fake_project = identity_fakes.FakeProject.create_one_project()
fake_messages = volume_fakes.FakeVolumeMessage.create_volume_messages(
count=3)
fake_messages = volume_fakes.create_volume_messages(count=3)
columns = (
'ID',
@ -253,7 +251,7 @@ class TestVolumeMessageList(TestVolumeMessage):
class TestVolumeMessageShow(TestVolumeMessage):
fake_message = volume_fakes.FakeVolumeMessage.create_one_volume_message()
fake_message = volume_fakes.create_one_volume_message()
columns = (
'created_at',