Skip to content

Commit 5faa9ef

Browse files
committed
tests: Rename 'FakeType' -> 'FakeVolumeType'
There are more types than just volume types. Change-Id: I6af66f966a221437ff79fabcb0b81fd38586fe67 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
1 parent 524af4a commit 5faa9ef

8 files changed

Lines changed: 91 additions & 84 deletions

File tree

openstackclient/tests/unit/volume/v1/fakes.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ def setUp(self):
400400
)
401401

402402

403-
class FakeType(object):
403+
class FakeVolumeType(object):
404404
"""Fake one or more type."""
405405

406406
@staticmethod
407-
def create_one_type(attrs=None, methods=None):
408-
"""Create a fake type.
407+
def create_one_volume_type(attrs=None, methods=None):
408+
"""Create a fake volume type.
409409
410410
:param Dictionary attrs:
411411
A dictionary with all attributes
@@ -418,7 +418,7 @@ def create_one_type(attrs=None, methods=None):
418418
methods = methods or {}
419419

420420
# Set default attributes.
421-
type_info = {
421+
volume_type_info = {
422422
"id": 'type-id-' + uuid.uuid4().hex,
423423
"name": 'type-name-' + uuid.uuid4().hex,
424424
"description": 'type-description-' + uuid.uuid4().hex,
@@ -427,16 +427,16 @@ def create_one_type(attrs=None, methods=None):
427427
}
428428

429429
# Overwrite default attributes.
430-
type_info.update(attrs)
430+
volume_type_info.update(attrs)
431431

432432
volume_type = fakes.FakeResource(
433-
info=copy.deepcopy(type_info),
433+
info=copy.deepcopy(volume_type_info),
434434
methods=methods,
435435
loaded=True)
436436
return volume_type
437437

438438
@staticmethod
439-
def create_types(attrs=None, count=2):
439+
def create_volume_types(attrs=None, count=2):
440440
"""Create multiple fake types.
441441
442442
:param Dictionary attrs:
@@ -448,34 +448,34 @@ def create_types(attrs=None, count=2):
448448
"""
449449
volume_types = []
450450
for i in range(0, count):
451-
volume_type = FakeType.create_one_type(attrs)
451+
volume_type = FakeVolumeType.create_one_volume_type(attrs)
452452
volume_types.append(volume_type)
453453

454454
return volume_types
455455

456456
@staticmethod
457-
def get_types(types=None, count=2):
457+
def get_volume_types(volume_types=None, count=2):
458458
"""Get an iterable MagicMock object with a list of faked types.
459459
460460
If types list is provided, then initialize the Mock object with the
461461
list. Otherwise create one.
462462
463-
:param List types:
463+
:param List volume_types:
464464
A list of FakeResource objects faking types
465465
:param Integer count:
466466
The number of types to be faked
467467
:return
468468
An iterable Mock object with side_effect set to a list of faked
469469
types
470470
"""
471-
if types is None:
472-
types = FakeType.create_types(count)
471+
if volume_types is None:
472+
volume_types = FakeVolumeType.create_volume_types(count)
473473

474-
return mock.Mock(side_effect=types)
474+
return mock.Mock(side_effect=volume_types)
475475

476476
@staticmethod
477-
def create_one_encryption_type(attrs=None):
478-
"""Create a fake encryption type.
477+
def create_one_encryption_volume_type(attrs=None):
478+
"""Create a fake encryption volume type.
479479
480480
:param Dictionary attrs:
481481
A dictionary with all attributes

openstackclient/tests/unit/volume/v1/test_qos_specs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def setUp(self):
3939

4040
class TestQosAssociate(TestQos):
4141

42-
volume_type = volume_fakes.FakeType.create_one_type()
42+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
4343
qos_spec = volume_fakes.FakeQos.create_one_qos()
4444

4545
def setUp(self):
@@ -263,7 +263,7 @@ def test_delete_multiple_qoses_with_exception(self):
263263

264264
class TestQosDisassociate(TestQos):
265265

266-
volume_type = volume_fakes.FakeType.create_one_type()
266+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
267267
qos_spec = volume_fakes.FakeQos.create_one_qos()
268268

269269
def setUp(self):

openstackclient/tests/unit/volume/v1/test_type.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class TestTypeCreate(TestType):
4949
def setUp(self):
5050
super(TestTypeCreate, self).setUp()
5151

52-
self.new_volume_type = volume_fakes.FakeType.create_one_type(
53-
methods={'set_keys': {'myprop': 'myvalue'}}
54-
)
52+
self.new_volume_type = \
53+
volume_fakes.FakeVolumeType.create_one_volume_type(
54+
methods={'set_keys': {'myprop': 'myvalue'}})
5555
self.data = (
5656
self.new_volume_type.description,
5757
self.new_volume_type.id,
@@ -87,11 +87,12 @@ def test_type_create_with_encryption(self):
8787
'key_size': '128',
8888
'control_location': 'front-end',
8989
}
90-
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
91-
attrs=encryption_info
92-
)
93-
self.new_volume_type = volume_fakes.FakeType.create_one_type(
94-
attrs={'encryption': encryption_info})
90+
encryption_type = \
91+
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
92+
attrs=encryption_info)
93+
self.new_volume_type = \
94+
volume_fakes.FakeVolumeType.create_one_volume_type(
95+
attrs={'encryption': encryption_info})
9596
self.types_mock.create.return_value = self.new_volume_type
9697
self.encryption_types_mock.create.return_value = encryption_type
9798
encryption_columns = (
@@ -144,12 +145,12 @@ def test_type_create_with_encryption(self):
144145

145146
class TestTypeDelete(TestType):
146147

147-
volume_types = volume_fakes.FakeType.create_types(count=2)
148+
volume_types = volume_fakes.FakeVolumeType.create_volume_types(count=2)
148149

149150
def setUp(self):
150151
super(TestTypeDelete, self).setUp()
151152

152-
self.types_mock.get = volume_fakes.FakeType.get_types(
153+
self.types_mock.get = volume_fakes.FakeVolumeType.get_volume_types(
153154
self.volume_types)
154155
self.types_mock.delete.return_value = None
155156

@@ -220,7 +221,7 @@ def test_delete_multiple_types_with_exception(self):
220221

221222
class TestTypeList(TestType):
222223

223-
volume_types = volume_fakes.FakeType.create_types()
224+
volume_types = volume_fakes.FakeVolumeType.create_volume_types()
224225

225226
columns = [
226227
"ID",
@@ -287,8 +288,9 @@ def test_type_list_with_options(self):
287288
self.assertItemsEqual(self.data_long, list(data))
288289

289290
def test_type_list_with_encryption(self):
290-
encryption_type = volume_fakes.FakeType.create_one_encryption_type(
291-
attrs={'volume_type_id': self.volume_types[0].id})
291+
encryption_type = \
292+
volume_fakes.FakeVolumeType.create_one_encryption_volume_type(
293+
attrs={'volume_type_id': self.volume_types[0].id})
292294
encryption_info = {
293295
'provider': 'LuksEncryptor',
294296
'cipher': None,
@@ -333,7 +335,7 @@ def test_type_list_with_encryption(self):
333335

334336
class TestTypeSet(TestType):
335337

336-
volume_type = volume_fakes.FakeType.create_one_type(
338+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
337339
methods={'set_keys': None})
338340

339341
def setUp(self):
@@ -441,7 +443,7 @@ class TestTypeShow(TestType):
441443
def setUp(self):
442444
super(TestTypeShow, self).setUp()
443445

444-
self.volume_type = volume_fakes.FakeType.create_one_type()
446+
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
445447
self.data = (
446448
self.volume_type.description,
447449
self.volume_type.id,
@@ -472,14 +474,15 @@ def test_type_show(self):
472474
self.assertItemsEqual(self.data, data)
473475

474476
def test_type_show_with_encryption(self):
475-
encryption_type = volume_fakes.FakeType.create_one_encryption_type()
477+
encryption_type = \
478+
volume_fakes.FakeVolumeType.create_one_encryption_volume_type()
476479
encryption_info = {
477480
'provider': 'LuksEncryptor',
478481
'cipher': None,
479482
'key_size': None,
480483
'control_location': 'front-end',
481484
}
482-
self.volume_type = volume_fakes.FakeType.create_one_type(
485+
self.volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
483486
attrs={'encryption': encryption_info})
484487
self.types_mock.get.return_value = self.volume_type
485488
self.encryption_types_mock.get.return_value = encryption_type
@@ -518,7 +521,7 @@ def test_type_show_with_encryption(self):
518521

519522
class TestTypeUnset(TestType):
520523

521-
volume_type = volume_fakes.FakeType.create_one_type(
524+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type(
522525
methods={'unset_keys': None})
523526

524527
def setUp(self):
@@ -596,7 +599,7 @@ def test_type_unset_encryption_type(self):
596599
class TestColumns(TestType):
597600

598601
def test_encryption_info_column_with_info(self):
599-
fake_volume_type = volume_fakes.FakeType.create_one_type()
602+
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
600603
type_id = fake_volume_type.id
601604

602605
encryption_info = {
@@ -612,7 +615,7 @@ def test_encryption_info_column_with_info(self):
612615
self.assertEqual(encryption_info, col.machine_readable())
613616

614617
def test_encryption_info_column_without_info(self):
615-
fake_volume_type = volume_fakes.FakeType.create_one_type()
618+
fake_volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
616619
type_id = fake_volume_type.id
617620

618621
col = volume_type.EncryptionInfoColumn(type_id, {})

openstackclient/tests/unit/volume/v2/fakes.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -983,12 +983,12 @@ def get_snapshots(snapshots=None, count=2):
983983
return mock.Mock(side_effect=snapshots)
984984

985985

986-
class FakeType(object):
987-
"""Fake one or more type."""
986+
class FakeVolumeType(object):
987+
"""Fake one or more volume type."""
988988

989989
@staticmethod
990-
def create_one_type(attrs=None, methods=None):
991-
"""Create a fake type.
990+
def create_one_volume_type(attrs=None, methods=None):
991+
"""Create a fake volume type.
992992
993993
:param Dictionary attrs:
994994
A dictionary with all attributes
@@ -1001,7 +1001,7 @@ def create_one_type(attrs=None, methods=None):
10011001
methods = methods or {}
10021002

10031003
# Set default attributes.
1004-
type_info = {
1004+
volume_type_info = {
10051005
"id": 'type-id-' + uuid.uuid4().hex,
10061006
"name": 'type-name-' + uuid.uuid4().hex,
10071007
"description": 'type-description-' + uuid.uuid4().hex,
@@ -1010,17 +1010,17 @@ def create_one_type(attrs=None, methods=None):
10101010
}
10111011

10121012
# Overwrite default attributes.
1013-
type_info.update(attrs)
1013+
volume_type_info.update(attrs)
10141014

10151015
volume_type = fakes.FakeResource(
1016-
info=copy.deepcopy(type_info),
1016+
info=copy.deepcopy(volume_type_info),
10171017
methods=methods,
10181018
loaded=True)
10191019
return volume_type
10201020

10211021
@staticmethod
1022-
def create_types(attrs=None, count=2):
1023-
"""Create multiple fake types.
1022+
def create_volume_types(attrs=None, count=2):
1023+
"""Create multiple fake volume_types.
10241024
10251025
:param Dictionary attrs:
10261026
A dictionary with all attributes
@@ -1031,34 +1031,34 @@ def create_types(attrs=None, count=2):
10311031
"""
10321032
volume_types = []
10331033
for i in range(0, count):
1034-
volume_type = FakeType.create_one_type(attrs)
1034+
volume_type = FakeVolumeType.create_one_volume_type(attrs)
10351035
volume_types.append(volume_type)
10361036

10371037
return volume_types
10381038

10391039
@staticmethod
1040-
def get_types(types=None, count=2):
1041-
"""Get an iterable MagicMock object with a list of faked types.
1040+
def get_volume_types(volume_types=None, count=2):
1041+
"""Get an iterable MagicMock object with a list of faked volume types.
10421042
1043-
If types list is provided, then initialize the Mock object with the
1044-
list. Otherwise create one.
1043+
If volume_types list is provided, then initialize the Mock object with
1044+
the list. Otherwise create one.
10451045
1046-
:param List types:
1047-
A list of FakeResource objects faking types
1046+
:param List volume_types:
1047+
A list of FakeResource objects faking volume types
10481048
:param Integer count:
1049-
The number of types to be faked
1049+
The number of volume types to be faked
10501050
:return
10511051
An iterable Mock object with side_effect set to a list of faked
1052-
types
1052+
volume types
10531053
"""
1054-
if types is None:
1055-
types = FakeType.create_types(count)
1054+
if volume_types is None:
1055+
volume_types = FakeVolumeType.create_volume_types(count)
10561056

1057-
return mock.Mock(side_effect=types)
1057+
return mock.Mock(side_effect=volume_types)
10581058

10591059
@staticmethod
1060-
def create_one_encryption_type(attrs=None):
1061-
"""Create a fake encryption type.
1060+
def create_one_encryption_volume_type(attrs=None):
1061+
"""Create a fake encryption volume type.
10621062
10631063
:param Dictionary attrs:
10641064
A dictionary with all attributes

openstackclient/tests/unit/volume/v2/test_consistency_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_add_multiple_volumes_to_consistency_group_with_exception(
148148

149149
class TestConsistencyGroupCreate(TestConsistencyGroup):
150150

151-
volume_type = volume_fakes.FakeType.create_one_type()
151+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
152152
new_consistency_group = (
153153
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
154154
consistency_group_snapshot = (

openstackclient/tests/unit/volume/v2/test_qos_specs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def setUp(self):
3939

4040
class TestQosAssociate(TestQos):
4141

42-
volume_type = volume_fakes.FakeType.create_one_type()
42+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
4343
qos_spec = volume_fakes.FakeQos.create_one_qos()
4444

4545
def setUp(self):
@@ -255,7 +255,7 @@ def test_delete_multiple_qoses_with_exception(self):
255255

256256
class TestQosDisassociate(TestQos):
257257

258-
volume_type = volume_fakes.FakeType.create_one_type()
258+
volume_type = volume_fakes.FakeVolumeType.create_one_volume_type()
259259
qos_spec = volume_fakes.FakeQos.create_one_qos()
260260

261261
def setUp(self):

0 commit comments

Comments
 (0)