tests: Rename 'FakeType' -> 'FakeVolumeType'
There are more types than just volume types. Change-Id: I6af66f966a221437ff79fabcb0b81fd38586fe67 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
@@ -400,12 +400,12 @@ class TestVolumev1(utils.TestCommand):
|
||||
)
|
||||
|
||||
|
||||
class FakeType(object):
|
||||
class FakeVolumeType(object):
|
||||
"""Fake one or more type."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_type(attrs=None, methods=None):
|
||||
"""Create a fake type.
|
||||
def create_one_volume_type(attrs=None, methods=None):
|
||||
"""Create a fake volume type.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
@@ -418,7 +418,7 @@ class FakeType(object):
|
||||
methods = methods or {}
|
||||
|
||||
# Set default attributes.
|
||||
type_info = {
|
||||
volume_type_info = {
|
||||
"id": 'type-id-' + uuid.uuid4().hex,
|
||||
"name": 'type-name-' + uuid.uuid4().hex,
|
||||
"description": 'type-description-' + uuid.uuid4().hex,
|
||||
@@ -427,16 +427,16 @@ class FakeType(object):
|
||||
}
|
||||
|
||||
# Overwrite default attributes.
|
||||
type_info.update(attrs)
|
||||
volume_type_info.update(attrs)
|
||||
|
||||
volume_type = fakes.FakeResource(
|
||||
info=copy.deepcopy(type_info),
|
||||
info=copy.deepcopy(volume_type_info),
|
||||
methods=methods,
|
||||
loaded=True)
|
||||
return volume_type
|
||||
|
||||
@staticmethod
|
||||
def create_types(attrs=None, count=2):
|
||||
def create_volume_types(attrs=None, count=2):
|
||||
"""Create multiple fake types.
|
||||
|
||||
:param Dictionary attrs:
|
||||
@@ -448,19 +448,19 @@ class FakeType(object):
|
||||
"""
|
||||
volume_types = []
|
||||
for i in range(0, count):
|
||||
volume_type = FakeType.create_one_type(attrs)
|
||||
volume_type = FakeVolumeType.create_one_volume_type(attrs)
|
||||
volume_types.append(volume_type)
|
||||
|
||||
return volume_types
|
||||
|
||||
@staticmethod
|
||||
def get_types(types=None, count=2):
|
||||
def get_volume_types(volume_types=None, count=2):
|
||||
"""Get an iterable MagicMock object with a list of faked types.
|
||||
|
||||
If types list is provided, then initialize the Mock object with the
|
||||
list. Otherwise create one.
|
||||
|
||||
:param List types:
|
||||
:param List volume_types:
|
||||
A list of FakeResource objects faking types
|
||||
:param Integer count:
|
||||
The number of types to be faked
|
||||
@@ -468,14 +468,14 @@ class FakeType(object):
|
||||
An iterable Mock object with side_effect set to a list of faked
|
||||
types
|
||||
"""
|
||||
if types is None:
|
||||
types = FakeType.create_types(count)
|
||||
if volume_types is None:
|
||||
volume_types = FakeVolumeType.create_volume_types(count)
|
||||
|
||||
return mock.Mock(side_effect=types)
|
||||
return mock.Mock(side_effect=volume_types)
|
||||
|
||||
@staticmethod
|
||||
def create_one_encryption_type(attrs=None):
|
||||
"""Create a fake encryption type.
|
||||
def create_one_encryption_volume_type(attrs=None):
|
||||
"""Create a fake encryption volume type.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
|
@@ -39,7 +39,7 @@ class TestQos(volume_fakes.TestVolumev1):
|
||||
|
||||
class TestQosAssociate(TestQos):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
qos_spec = volume_fakes.FakeQos.create_one_qos()
|
||||
|
||||
def setUp(self):
|
||||
@@ -263,7 +263,7 @@ class TestQosDelete(TestQos):
|
||||
|
||||
class TestQosDisassociate(TestQos):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
qos_spec = volume_fakes.FakeQos.create_one_qos()
|
||||
|
||||
def setUp(self):
|
||||
|
@@ -49,9 +49,9 @@ class TestTypeCreate(TestType):
|
||||
def setUp(self):
|
||||
super(TestTypeCreate, self).setUp()
|
||||
|
||||
self.new_volume_type = volume_fakes.FakeType.create_one_type(
|
||||
methods={'set_keys': {'myprop': 'myvalue'}}
|
||||
)
|
||||
self.new_volume_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
methods={'set_keys': {'myprop': 'myvalue'}})
|
||||
self.data = (
|
||||
self.new_volume_type.description,
|
||||
self.new_volume_type.id,
|
||||
@@ -87,11 +87,12 @@ class TestTypeCreate(TestType):
|
||||
'key_size': '128',
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
|
||||
attrs=encryption_info
|
||||
)
|
||||
self.new_volume_type = volume_fakes.FakeType.create_one_type(
|
||||
attrs={'encryption': encryption_info})
|
||||
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})
|
||||
self.types_mock.create.return_value = self.new_volume_type
|
||||
self.encryption_types_mock.create.return_value = encryption_type
|
||||
encryption_columns = (
|
||||
@@ -144,12 +145,12 @@ class TestTypeCreate(TestType):
|
||||
|
||||
class TestTypeDelete(TestType):
|
||||
|
||||
volume_types = volume_fakes.FakeType.create_types(count=2)
|
||||
volume_types = volume_fakes.FakeVolumeType.create_volume_types(count=2)
|
||||
|
||||
def setUp(self):
|
||||
super(TestTypeDelete, self).setUp()
|
||||
|
||||
self.types_mock.get = volume_fakes.FakeType.get_types(
|
||||
self.types_mock.get = volume_fakes.FakeVolumeType.get_volume_types(
|
||||
self.volume_types)
|
||||
self.types_mock.delete.return_value = None
|
||||
|
||||
@@ -220,7 +221,7 @@ class TestTypeDelete(TestType):
|
||||
|
||||
class TestTypeList(TestType):
|
||||
|
||||
volume_types = volume_fakes.FakeType.create_types()
|
||||
volume_types = volume_fakes.FakeVolumeType.create_volume_types()
|
||||
|
||||
columns = [
|
||||
"ID",
|
||||
@@ -287,8 +288,9 @@ class TestTypeList(TestType):
|
||||
self.assertItemsEqual(self.data_long, list(data))
|
||||
|
||||
def test_type_list_with_encryption(self):
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
|
||||
attrs={'volume_type_id': self.volume_types[0].id})
|
||||
encryption_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
|
||||
attrs={'volume_type_id': self.volume_types[0].id})
|
||||
encryption_info = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': None,
|
||||
@@ -333,7 +335,7 @@ class TestTypeList(TestType):
|
||||
|
||||
class TestTypeSet(TestType):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type(
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
methods={'set_keys': None})
|
||||
|
||||
def setUp(self):
|
||||
@@ -441,7 +443,7 @@ class TestTypeShow(TestType):
|
||||
def setUp(self):
|
||||
super(TestTypeShow, self).setUp()
|
||||
|
||||
self.volume_type = volume_fakes.FakeType.create_one_type()
|
||||
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
self.data = (
|
||||
self.volume_type.description,
|
||||
self.volume_type.id,
|
||||
@@ -472,14 +474,15 @@ class TestTypeShow(TestType):
|
||||
self.assertItemsEqual(self.data, data)
|
||||
|
||||
def test_type_show_with_encryption(self):
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type()
|
||||
encryption_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_encryption_volume_type()
|
||||
encryption_info = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': None,
|
||||
'key_size': None,
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
self.volume_type = volume_fakes.FakeType.create_one_type(
|
||||
self.volume_type = volume_fakes.FakeVolumeType.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
|
||||
@@ -518,7 +521,7 @@ class TestTypeShow(TestType):
|
||||
|
||||
class TestTypeUnset(TestType):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type(
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
methods={'unset_keys': None})
|
||||
|
||||
def setUp(self):
|
||||
@@ -596,7 +599,7 @@ class TestTypeUnset(TestType):
|
||||
class TestColumns(TestType):
|
||||
|
||||
def test_encryption_info_column_with_info(self):
|
||||
fake_volume_type = volume_fakes.FakeType.create_one_type()
|
||||
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
type_id = fake_volume_type.id
|
||||
|
||||
encryption_info = {
|
||||
@@ -612,7 +615,7 @@ class TestColumns(TestType):
|
||||
self.assertEqual(encryption_info, col.machine_readable())
|
||||
|
||||
def test_encryption_info_column_without_info(self):
|
||||
fake_volume_type = volume_fakes.FakeType.create_one_type()
|
||||
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
type_id = fake_volume_type.id
|
||||
|
||||
col = volume_type.EncryptionInfoColumn(type_id, {})
|
||||
|
@@ -983,12 +983,12 @@ class FakeSnapshot(object):
|
||||
return mock.Mock(side_effect=snapshots)
|
||||
|
||||
|
||||
class FakeType(object):
|
||||
"""Fake one or more type."""
|
||||
class FakeVolumeType(object):
|
||||
"""Fake one or more volume type."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_type(attrs=None, methods=None):
|
||||
"""Create a fake type.
|
||||
def create_one_volume_type(attrs=None, methods=None):
|
||||
"""Create a fake volume type.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
@@ -1001,7 +1001,7 @@ class FakeType(object):
|
||||
methods = methods or {}
|
||||
|
||||
# Set default attributes.
|
||||
type_info = {
|
||||
volume_type_info = {
|
||||
"id": 'type-id-' + uuid.uuid4().hex,
|
||||
"name": 'type-name-' + uuid.uuid4().hex,
|
||||
"description": 'type-description-' + uuid.uuid4().hex,
|
||||
@@ -1010,17 +1010,17 @@ class FakeType(object):
|
||||
}
|
||||
|
||||
# Overwrite default attributes.
|
||||
type_info.update(attrs)
|
||||
volume_type_info.update(attrs)
|
||||
|
||||
volume_type = fakes.FakeResource(
|
||||
info=copy.deepcopy(type_info),
|
||||
info=copy.deepcopy(volume_type_info),
|
||||
methods=methods,
|
||||
loaded=True)
|
||||
return volume_type
|
||||
|
||||
@staticmethod
|
||||
def create_types(attrs=None, count=2):
|
||||
"""Create multiple fake types.
|
||||
def create_volume_types(attrs=None, count=2):
|
||||
"""Create multiple fake volume_types.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
@@ -1031,34 +1031,34 @@ class FakeType(object):
|
||||
"""
|
||||
volume_types = []
|
||||
for i in range(0, count):
|
||||
volume_type = FakeType.create_one_type(attrs)
|
||||
volume_type = FakeVolumeType.create_one_volume_type(attrs)
|
||||
volume_types.append(volume_type)
|
||||
|
||||
return volume_types
|
||||
|
||||
@staticmethod
|
||||
def get_types(types=None, count=2):
|
||||
"""Get an iterable MagicMock object with a list of faked types.
|
||||
def get_volume_types(volume_types=None, count=2):
|
||||
"""Get an iterable MagicMock object with a list of faked volume types.
|
||||
|
||||
If types list is provided, then initialize the Mock object with the
|
||||
list. Otherwise create one.
|
||||
If volume_types list is provided, then initialize the Mock object with
|
||||
the list. Otherwise create one.
|
||||
|
||||
:param List types:
|
||||
A list of FakeResource objects faking types
|
||||
:param List volume_types:
|
||||
A list of FakeResource objects faking volume types
|
||||
:param Integer count:
|
||||
The number of types to be faked
|
||||
The number of volume types to be faked
|
||||
:return
|
||||
An iterable Mock object with side_effect set to a list of faked
|
||||
types
|
||||
volume types
|
||||
"""
|
||||
if types is None:
|
||||
types = FakeType.create_types(count)
|
||||
if volume_types is None:
|
||||
volume_types = FakeVolumeType.create_volume_types(count)
|
||||
|
||||
return mock.Mock(side_effect=types)
|
||||
return mock.Mock(side_effect=volume_types)
|
||||
|
||||
@staticmethod
|
||||
def create_one_encryption_type(attrs=None):
|
||||
"""Create a fake encryption type.
|
||||
def create_one_encryption_volume_type(attrs=None):
|
||||
"""Create a fake encryption volume type.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
|
@@ -148,7 +148,7 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
|
||||
|
||||
class TestConsistencyGroupCreate(TestConsistencyGroup):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
new_consistency_group = (
|
||||
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
|
||||
consistency_group_snapshot = (
|
||||
|
@@ -39,7 +39,7 @@ class TestQos(volume_fakes.TestVolume):
|
||||
|
||||
class TestQosAssociate(TestQos):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
qos_spec = volume_fakes.FakeQos.create_one_qos()
|
||||
|
||||
def setUp(self):
|
||||
@@ -255,7 +255,7 @@ class TestQosDelete(TestQos):
|
||||
|
||||
class TestQosDisassociate(TestQos):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
qos_spec = volume_fakes.FakeQos.create_one_qos()
|
||||
|
||||
def setUp(self):
|
||||
|
@@ -58,7 +58,8 @@ class TestTypeCreate(TestType):
|
||||
def setUp(self):
|
||||
super(TestTypeCreate, self).setUp()
|
||||
|
||||
self.new_volume_type = volume_fakes.FakeType.create_one_type()
|
||||
self.new_volume_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
self.data = (
|
||||
self.new_volume_type.description,
|
||||
self.new_volume_type.id,
|
||||
@@ -143,11 +144,12 @@ class TestTypeCreate(TestType):
|
||||
'key_size': '128',
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
|
||||
attrs=encryption_info
|
||||
)
|
||||
self.new_volume_type = volume_fakes.FakeType.create_one_type(
|
||||
attrs={'encryption': encryption_info})
|
||||
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})
|
||||
self.types_mock.create.return_value = self.new_volume_type
|
||||
self.encryption_types_mock.create.return_value = encryption_type
|
||||
encryption_columns = (
|
||||
@@ -201,12 +203,12 @@ class TestTypeCreate(TestType):
|
||||
|
||||
class TestTypeDelete(TestType):
|
||||
|
||||
volume_types = volume_fakes.FakeType.create_types(count=2)
|
||||
volume_types = volume_fakes.FakeVolumeType.create_volume_types(count=2)
|
||||
|
||||
def setUp(self):
|
||||
super(TestTypeDelete, self).setUp()
|
||||
|
||||
self.types_mock.get = volume_fakes.FakeType.get_types(
|
||||
self.types_mock.get = volume_fakes.FakeVolumeType.get_volume_types(
|
||||
self.volume_types)
|
||||
self.types_mock.delete.return_value = None
|
||||
|
||||
@@ -276,7 +278,7 @@ class TestTypeDelete(TestType):
|
||||
|
||||
class TestTypeList(TestType):
|
||||
|
||||
volume_types = volume_fakes.FakeType.create_types()
|
||||
volume_types = volume_fakes.FakeVolumeType.create_volume_types()
|
||||
|
||||
columns = [
|
||||
"ID",
|
||||
@@ -386,8 +388,9 @@ class TestTypeList(TestType):
|
||||
self.assertItemsEqual(self.data_with_default_type, list(data))
|
||||
|
||||
def test_type_list_with_encryption(self):
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
|
||||
attrs={'volume_type_id': self.volume_types[0].id})
|
||||
encryption_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
|
||||
attrs={'volume_type_id': self.volume_types[0].id})
|
||||
encryption_info = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': None,
|
||||
@@ -433,7 +436,7 @@ class TestTypeList(TestType):
|
||||
class TestTypeSet(TestType):
|
||||
|
||||
project = identity_fakes.FakeProject.create_one_project()
|
||||
volume_type = volume_fakes.FakeType.create_one_type(
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
methods={'set_keys': None})
|
||||
|
||||
def setUp(self):
|
||||
@@ -684,7 +687,7 @@ class TestTypeShow(TestType):
|
||||
def setUp(self):
|
||||
super(TestTypeShow, self).setUp()
|
||||
|
||||
self.volume_type = volume_fakes.FakeType.create_one_type()
|
||||
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
self.data = (
|
||||
None,
|
||||
self.volume_type.description,
|
||||
@@ -724,7 +727,7 @@ class TestTypeShow(TestType):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
private_type = volume_fakes.FakeType.create_one_type(
|
||||
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',
|
||||
@@ -757,7 +760,7 @@ class TestTypeShow(TestType):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
private_type = volume_fakes.FakeType.create_one_type(
|
||||
private_type = volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
attrs={'is_public': False})
|
||||
with mock.patch.object(self.types_mock, 'get',
|
||||
return_value=private_type):
|
||||
@@ -781,14 +784,15 @@ class TestTypeShow(TestType):
|
||||
self.assertItemsEqual(private_type_data, data)
|
||||
|
||||
def test_type_show_with_encryption(self):
|
||||
encryption_type = volume_fakes.FakeType.create_one_encryption_type()
|
||||
encryption_type = \
|
||||
volume_fakes.FakeVolumeType.create_one_encryption_volume_type()
|
||||
encryption_info = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': None,
|
||||
'key_size': None,
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
self.volume_type = volume_fakes.FakeType.create_one_type(
|
||||
self.volume_type = volume_fakes.FakeVolumeType.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
|
||||
@@ -830,7 +834,7 @@ class TestTypeShow(TestType):
|
||||
class TestTypeUnset(TestType):
|
||||
|
||||
project = identity_fakes.FakeProject.create_one_project()
|
||||
volume_type = volume_fakes.FakeType.create_one_type(
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
|
||||
methods={'unset_keys': None})
|
||||
|
||||
def setUp(self):
|
||||
@@ -932,7 +936,7 @@ class TestTypeUnset(TestType):
|
||||
class TestColumns(TestType):
|
||||
|
||||
def test_encryption_info_column_with_info(self):
|
||||
fake_volume_type = volume_fakes.FakeType.create_one_type()
|
||||
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
type_id = fake_volume_type.id
|
||||
|
||||
encryption_info = {
|
||||
@@ -948,7 +952,7 @@ class TestColumns(TestType):
|
||||
self.assertEqual(encryption_info, col.machine_readable())
|
||||
|
||||
def test_encryption_info_column_without_info(self):
|
||||
fake_volume_type = volume_fakes.FakeType.create_one_type()
|
||||
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
type_id = fake_volume_type.id
|
||||
|
||||
col = volume_type.EncryptionInfoColumn(type_id, {})
|
||||
|
@@ -1173,7 +1173,7 @@ class TestVolumeMigrate(TestVolume):
|
||||
|
||||
class TestVolumeSet(TestVolume):
|
||||
|
||||
volume_type = volume_fakes.FakeType.create_one_type()
|
||||
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeSet, self).setUp()
|
||||
|
Reference in New Issue
Block a user