Skip to content

Commit c4edd54

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "volume: Migrate 'volume type *' to SDK"
2 parents 1ac161f + d3ab1c9 commit c4edd54

8 files changed

Lines changed: 849 additions & 959 deletions

File tree

openstackclient/tests/functional/volume/v3/test_volume_type.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def test_multi_delete(self):
138138
def test_encryption_type(self):
139139
name = uuid.uuid4().hex
140140
encryption_type = uuid.uuid4().hex
141+
141142
# test create new encryption type
142143
cmd_output = self.openstack(
143144
'volume type create '
@@ -155,6 +156,7 @@ def test_encryption_type(self):
155156
}
156157
for attr, value in expected.items():
157158
self.assertEqual(value, cmd_output['encryption'][attr])
159+
158160
# test show encryption type
159161
cmd_output = self.openstack(
160162
'volume type show --encryption-type ' + encryption_type,
@@ -168,6 +170,7 @@ def test_encryption_type(self):
168170
}
169171
for attr, value in expected.items():
170172
self.assertEqual(value, cmd_output['encryption'][attr])
173+
171174
# test list encryption type
172175
cmd_output = self.openstack(
173176
'volume type list --encryption-type',
@@ -184,6 +187,7 @@ def test_encryption_type(self):
184187
}
185188
for attr, value in expected.items():
186189
self.assertEqual(value, encryption_output[attr])
190+
187191
# test set existing encryption type
188192
raw_output = self.openstack(
189193
'volume type set '
@@ -203,6 +207,7 @@ def test_encryption_type(self):
203207
}
204208
for attr, value in expected.items():
205209
self.assertEqual(value, cmd_output['encryption'][attr])
210+
206211
# test set new encryption type
207212
cmd_output = self.openstack(
208213
'volume type create --private ' + name,
@@ -235,6 +240,7 @@ def test_encryption_type(self):
235240
}
236241
for attr, value in expected.items():
237242
self.assertEqual(value, cmd_output['encryption'][attr])
243+
238244
# test unset encryption type
239245
raw_output = self.openstack(
240246
'volume type unset --encryption-type ' + name
@@ -245,6 +251,7 @@ def test_encryption_type(self):
245251
parse_output=True,
246252
)
247253
self.assertEqual({}, cmd_output['encryption'])
254+
248255
# test delete encryption type
249256
raw_output = self.openstack('volume type delete ' + encryption_type)
250257
self.assertEqual('', raw_output)

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

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,8 @@ def __init__(self, **kwargs):
5050
self.services.resource_class = fakes.FakeResource(None, {})
5151
self.transfers = mock.Mock()
5252
self.transfers.resource_class = fakes.FakeResource(None, {})
53-
self.volume_encryption_types = mock.Mock()
54-
self.volume_encryption_types.resource_class = fakes.FakeResource(
55-
None, {}
56-
)
5753
self.volume_snapshots = mock.Mock()
5854
self.volume_snapshots.resource_class = fakes.FakeResource(None, {})
59-
self.volume_type_access = mock.Mock()
60-
self.volume_type_access.resource_class = fakes.FakeResource(None, {})
6155
self.volume_types = mock.Mock()
6256
self.volume_types.resource_class = fakes.FakeResource(None, {})
6357
self.volumes = mock.Mock()
@@ -179,31 +173,6 @@ def get_transfers(transfers=None, count=2):
179173
return mock.Mock(side_effect=transfers)
180174

181175

182-
def create_one_type_access(attrs=None):
183-
"""Create a fake volume type access for project.
184-
185-
:param dict attrs:
186-
A dictionary with all attributes
187-
:return:
188-
A FakeResource object, with Volume_type_ID and Project_ID.
189-
"""
190-
if attrs is None:
191-
attrs = {}
192-
193-
# Set default attributes.
194-
type_access_attrs = {
195-
'volume_type_id': 'volume-type-id-' + uuid.uuid4().hex,
196-
'project_id': 'project-id-' + uuid.uuid4().hex,
197-
}
198-
199-
# Overwrite default attributes.
200-
type_access_attrs.update(attrs)
201-
202-
type_access = fakes.FakeResource(None, type_access_attrs, loaded=True)
203-
204-
return type_access
205-
206-
207176
def create_one_service(attrs=None):
208177
"""Create a fake service.
209178
@@ -788,69 +757,3 @@ def create_one_volume_type(attrs=None, methods=None):
788757
info=copy.deepcopy(volume_type_info), methods=methods, loaded=True
789758
)
790759
return volume_type
791-
792-
793-
def create_volume_types(attrs=None, count=2):
794-
"""Create multiple fake volume_types.
795-
796-
:param dict attrs:
797-
A dictionary with all attributes
798-
:param int count:
799-
The number of types to fake
800-
:return:
801-
A list of FakeResource objects faking the types
802-
"""
803-
volume_types = []
804-
for i in range(0, count):
805-
volume_type = create_one_volume_type(attrs)
806-
volume_types.append(volume_type)
807-
808-
return volume_types
809-
810-
811-
def get_volume_types(volume_types=None, count=2):
812-
"""Get an iterable MagicMock object with a list of faked volume types.
813-
814-
If volume_types list is provided, then initialize the Mock object with
815-
the list. Otherwise create one.
816-
817-
:param List volume_types:
818-
A list of FakeResource objects faking volume types
819-
:param Integer count:
820-
The number of volume types to be faked
821-
:return
822-
An iterable Mock object with side_effect set to a list of faked
823-
volume types
824-
"""
825-
if volume_types is None:
826-
volume_types = create_volume_types(count)
827-
828-
return mock.Mock(side_effect=volume_types)
829-
830-
831-
def create_one_encryption_volume_type(attrs=None):
832-
"""Create a fake encryption volume type.
833-
834-
:param dict attrs:
835-
A dictionary with all attributes
836-
:return:
837-
A FakeResource object with volume_type_id etc.
838-
"""
839-
attrs = attrs or {}
840-
841-
# Set default attributes.
842-
encryption_info = {
843-
"volume_type_id": 'type-id-' + uuid.uuid4().hex,
844-
'provider': 'LuksEncryptor',
845-
'cipher': None,
846-
'key_size': None,
847-
'control_location': 'front-end',
848-
}
849-
850-
# Overwrite default attributes.
851-
encryption_info.update(attrs)
852-
853-
encryption_type = fakes.FakeResource(
854-
info=copy.deepcopy(encryption_info), loaded=True
855-
)
856-
return encryption_type

0 commit comments

Comments
 (0)