Skip to content

Commit cbbbd9e

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Use cliff formattable columns in volume v2 commands" into feature/osc4
2 parents 3ac84c4 + b0dc1aa commit cbbbd9e

File tree

18 files changed

+393
-260
lines changed

18 files changed

+393
-260
lines changed

openstackclient/tests/functional/volume/v2/test_qos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_volume_qos_set_show_unset(self):
7474
cmd_output['consumer']
7575
)
7676
self.assertEqual(
77-
"Alpha='a'",
77+
{'Alpha': 'a'},
7878
cmd_output['properties']
7979
)
8080

@@ -97,7 +97,7 @@ def test_volume_qos_set_show_unset(self):
9797
cmd_output['name']
9898
)
9999
self.assertEqual(
100-
"Alpha='c', Beta='b'",
100+
{'Alpha': 'c', 'Beta': 'b'},
101101
cmd_output['properties']
102102
)
103103

@@ -118,7 +118,7 @@ def test_volume_qos_set_show_unset(self):
118118
cmd_output['name']
119119
)
120120
self.assertEqual(
121-
"Beta='b'",
121+
{'Beta': 'b'},
122122
cmd_output['properties']
123123
)
124124

openstackclient/tests/functional/volume/v2/test_snapshot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_volume_snapshot_set(self):
182182
cmd_output["description"],
183183
)
184184
self.assertEqual(
185-
"Alpha='a'",
185+
{'Alpha': 'a'},
186186
cmd_output["properties"],
187187
)
188188
self.wait_for_status('volume snapshot', name, 'available')
@@ -216,7 +216,7 @@ def test_volume_snapshot_set(self):
216216
cmd_output["description"],
217217
)
218218
self.assertEqual(
219-
"Alpha='c', Beta='b'",
219+
{'Alpha': 'c', 'Beta': 'b'},
220220
cmd_output["properties"],
221221
)
222222

@@ -233,7 +233,7 @@ def test_volume_snapshot_set(self):
233233
new_name
234234
))
235235
self.assertEqual(
236-
"Beta='b'",
236+
{'Beta': 'b'},
237237
cmd_output["properties"],
238238
)
239239

@@ -249,6 +249,6 @@ def test_volume_snapshot_set(self):
249249
new_name
250250
))
251251
self.assertNotIn(
252-
"Beta='b'",
252+
{'Beta': 'b'},
253253
cmd_output["properties"],
254254
)

openstackclient/tests/functional/volume/v2/test_volume.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_volume_set_and_unset(self):
128128
cmd_output["description"],
129129
)
130130
self.assertEqual(
131-
"Alpha='a'",
131+
{'Alpha': 'a'},
132132
cmd_output["properties"],
133133
)
134134
self.assertEqual(
@@ -170,7 +170,7 @@ def test_volume_set_and_unset(self):
170170
cmd_output["description"],
171171
)
172172
self.assertEqual(
173-
"Beta='b', Gamma='c'",
173+
{'Beta': 'b', 'Gamma': 'c'},
174174
cmd_output["properties"],
175175
)
176176
self.assertEqual(
@@ -196,7 +196,7 @@ def test_volume_set_and_unset(self):
196196
new_name
197197
))
198198
self.assertEqual(
199-
"Gamma='c'",
199+
{'Gamma': 'c'},
200200
cmd_output["properties"],
201201
)
202202
self.assertEqual(

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

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,29 @@ def test_volume_type_set_unset_properties(self):
5858
self.assertEqual("", raw_output)
5959
cmd_output = json.loads(self.openstack(
6060
'volume type show -f json ' + self.NAME))
61-
# TODO(amotoki): properties output should be machine-readable
62-
self.assertEqual("a='b', c='d'", cmd_output['properties'])
61+
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
6362

6463
raw_output = self.openstack('volume type unset --property a '
6564
+ self.NAME)
6665
self.assertEqual("", raw_output)
6766
cmd_output = json.loads(self.openstack(
6867
'volume type show -f json ' + self.NAME))
69-
self.assertEqual("c='d'", cmd_output['properties'])
68+
self.assertEqual({'c': 'd'}, cmd_output['properties'])
7069

7170
def test_volume_type_set_unset_multiple_properties(self):
7271
raw_output = self.openstack(
7372
'volume type set --property a=b --property c=d ' + self.NAME)
7473
self.assertEqual("", raw_output)
7574
cmd_output = json.loads(self.openstack(
7675
'volume type show -f json ' + self.NAME))
77-
self.assertEqual("a='b', c='d'", cmd_output['properties'])
76+
self.assertEqual({'a': 'b', 'c': 'd'}, cmd_output['properties'])
7877

7978
raw_output = self.openstack(
8079
'volume type unset --property a --property c ' + self.NAME)
8180
self.assertEqual("", raw_output)
8281
cmd_output = json.loads(self.openstack(
8382
'volume type show -f json ' + self.NAME))
84-
self.assertEqual("", cmd_output['properties'])
83+
self.assertEqual({}, cmd_output['properties'])
8584

8685
def test_volume_type_set_unset_project(self):
8786
raw_output = self.openstack(
@@ -117,35 +116,32 @@ def test_encryption_type(self):
117116
'--encryption-key-size 128 '
118117
'--encryption-control-location front-end ' +
119118
encryption_type))
120-
# TODO(amotoki): encryption output should be machine-readable
121-
expected = ["provider='LuksEncryptor'",
122-
"cipher='aes-xts-plain64'",
123-
"key_size='128'",
124-
"control_location='front-end'"]
125-
for attr in expected:
126-
self.assertIn(attr, cmd_output['encryption'])
119+
expected = {'provider': 'LuksEncryptor',
120+
'cipher': 'aes-xts-plain64',
121+
'key_size': 128,
122+
'control_location': 'front-end'}
123+
for attr, value in expected.items():
124+
self.assertEqual(value, cmd_output['encryption'][attr])
127125
# test show encryption type
128126
cmd_output = json.loads(self.openstack(
129127
'volume type show -f json --encryption-type ' + encryption_type))
130-
# TODO(amotoki): encryption output should be machine-readable
131-
expected = ["provider='LuksEncryptor'",
132-
"cipher='aes-xts-plain64'",
133-
"key_size='128'",
134-
"control_location='front-end'"]
135-
for attr in expected:
136-
self.assertIn(attr, cmd_output['encryption'])
128+
expected = {'provider': 'LuksEncryptor',
129+
'cipher': 'aes-xts-plain64',
130+
'key_size': 128,
131+
'control_location': 'front-end'}
132+
for attr, value in expected.items():
133+
self.assertEqual(value, cmd_output['encryption'][attr])
137134
# test list encryption type
138135
cmd_output = json.loads(self.openstack(
139136
'volume type list -f json --encryption-type'))
140137
encryption_output = [t['Encryption'] for t in cmd_output
141138
if t['Name'] == encryption_type][0]
142-
# TODO(amotoki): encryption output should be machine-readable
143-
expected = ["provider='LuksEncryptor'",
144-
"cipher='aes-xts-plain64'",
145-
"key_size='128'",
146-
"control_location='front-end'"]
147-
for attr in expected:
148-
self.assertIn(attr, encryption_output)
139+
expected = {'provider': 'LuksEncryptor',
140+
'cipher': 'aes-xts-plain64',
141+
'key_size': 128,
142+
'control_location': 'front-end'}
143+
for attr, value in expected.items():
144+
self.assertEqual(value, encryption_output[attr])
149145
# test set existing encryption type
150146
raw_output = self.openstack(
151147
'volume type set '
@@ -155,12 +151,12 @@ def test_encryption_type(self):
155151
self.assertEqual('', raw_output)
156152
cmd_output = json.loads(self.openstack(
157153
'volume type show -f json --encryption-type ' + encryption_type))
158-
expected = ["provider='LuksEncryptor'",
159-
"cipher='aes-xts-plain64'",
160-
"key_size='256'",
161-
"control_location='back-end'"]
162-
for attr in expected:
163-
self.assertIn(attr, cmd_output['encryption'])
154+
expected = {'provider': 'LuksEncryptor',
155+
'cipher': 'aes-xts-plain64',
156+
'key_size': 256,
157+
'control_location': 'back-end'}
158+
for attr, value in expected.items():
159+
self.assertEqual(value, cmd_output['encryption'][attr])
164160
# test set new encryption type
165161
raw_output = self.openstack(
166162
'volume type set '
@@ -172,19 +168,19 @@ def test_encryption_type(self):
172168
self.assertEqual('', raw_output)
173169
cmd_output = json.loads(self.openstack(
174170
'volume type show -f json --encryption-type ' + self.NAME))
175-
expected = ["provider='LuksEncryptor'",
176-
"cipher='aes-xts-plain64'",
177-
"key_size='128'",
178-
"control_location='front-end'"]
179-
for attr in expected:
180-
self.assertIn(attr, cmd_output['encryption'])
171+
expected = {'provider': 'LuksEncryptor',
172+
'cipher': 'aes-xts-plain64',
173+
'key_size': 128,
174+
'control_location': 'front-end'}
175+
for attr, value in expected.items():
176+
self.assertEqual(value, cmd_output['encryption'][attr])
181177
# test unset encryption type
182178
raw_output = self.openstack(
183179
'volume type unset --encryption-type ' + self.NAME)
184180
self.assertEqual('', raw_output)
185181
cmd_output = json.loads(self.openstack(
186182
'volume type show -f json --encryption-type ' + self.NAME))
187-
self.assertEqual('', cmd_output['encryption'])
183+
self.assertEqual({}, cmd_output['encryption'])
188184
# test delete encryption type
189185
raw_output = self.openstack('volume type delete ' + encryption_type)
190186
self.assertEqual('', raw_output)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import random
1818
import uuid
1919

20-
from osc_lib import utils as common_utils
20+
from osc_lib.cli import format_columns
2121

2222
from openstackclient.tests.unit import fakes
2323
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
@@ -368,7 +368,7 @@ def get_volume_data(volume=None):
368368
if x == 'tags':
369369
# The 'tags' should be format_list
370370
data_list.append(
371-
common_utils.format_list(volume.info.get(x)))
371+
format_columns.ListColumn(volume.info.get(x)))
372372
else:
373373
data_list.append(volume.info.get(x))
374374
return tuple(data_list)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class TestBackupList(TestBackup):
271271
b.status,
272272
b.size,
273273
b.availability_zone,
274-
b.volume_id,
274+
backup.VolumeIdColumn(b.volume_id),
275275
b.container,
276276
))
277277

@@ -314,7 +314,7 @@ def test_backup_list_without_options(self):
314314
limit=None,
315315
)
316316
self.assertEqual(self.columns, columns)
317-
self.assertEqual(self.data, list(data))
317+
self.assertListItemEqual(self.data, list(data))
318318

319319
def test_backup_list_with_options(self):
320320
arglist = [
@@ -353,7 +353,7 @@ def test_backup_list_with_options(self):
353353
limit=3,
354354
)
355355
self.assertEqual(self.columns_long, columns)
356-
self.assertEqual(self.data_long, list(data))
356+
self.assertListItemEqual(self.data_long, list(data))
357357

358358

359359
class TestBackupRestore(TestBackup):

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import mock
1616
from mock import call
1717

18+
from osc_lib.cli import format_columns
1819
from osc_lib import exceptions
1920
from osc_lib import utils
2021

@@ -250,7 +251,7 @@ def test_consistency_group_create_without_name(self):
250251
)
251252

252253
self.assertEqual(self.columns, columns)
253-
self.assertEqual(self.data, data)
254+
self.assertItemEqual(self.data, data)
254255

255256
def test_consistency_group_create_from_source(self):
256257
arglist = [
@@ -278,7 +279,7 @@ def test_consistency_group_create_from_source(self):
278279
)
279280

280281
self.assertEqual(self.columns, columns)
281-
self.assertEqual(self.data, data)
282+
self.assertItemEqual(self.data, data)
282283

283284
def test_consistency_group_create_from_snapshot(self):
284285
arglist = [
@@ -306,7 +307,7 @@ def test_consistency_group_create_from_snapshot(self):
306307
)
307308

308309
self.assertEqual(self.columns, columns)
309-
self.assertEqual(self.data, data)
310+
self.assertItemEqual(self.data, data)
310311

311312

312313
class TestConsistencyGroupDelete(TestConsistencyGroup):
@@ -439,7 +440,7 @@ class TestConsistencyGroupList(TestConsistencyGroup):
439440
c.availability_zone,
440441
c.name,
441442
c.description,
442-
utils.format_list(c.volume_types)
443+
format_columns.ListColumn(c.volume_types)
443444
))
444445

445446
def setUp(self):
@@ -462,7 +463,7 @@ def test_consistency_group_list_without_options(self):
462463
self.consistencygroups_mock.list.assert_called_once_with(
463464
detailed=True, search_opts={'all_tenants': False})
464465
self.assertEqual(self.columns, columns)
465-
self.assertEqual(self.data, list(data))
466+
self.assertListItemEqual(self.data, list(data))
466467

467468
def test_consistency_group_list_with_all_project(self):
468469
arglist = [
@@ -479,7 +480,7 @@ def test_consistency_group_list_with_all_project(self):
479480
self.consistencygroups_mock.list.assert_called_once_with(
480481
detailed=True, search_opts={'all_tenants': True})
481482
self.assertEqual(self.columns, columns)
482-
self.assertEqual(self.data, list(data))
483+
self.assertListItemEqual(self.data, list(data))
483484

484485
def test_consistency_group_list_with_long(self):
485486
arglist = [
@@ -496,7 +497,7 @@ def test_consistency_group_list_with_long(self):
496497
self.consistencygroups_mock.list.assert_called_once_with(
497498
detailed=True, search_opts={'all_tenants': False})
498499
self.assertEqual(self.columns_long, columns)
499-
self.assertEqual(self.data_long, list(data))
500+
self.assertListItemEqual(self.data_long, list(data))
500501

501502

502503
class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
@@ -704,4 +705,4 @@ def test_consistency_group_show(self):
704705
self.consistencygroups_mock.get.assert_called_once_with(
705706
self.consistency_group.id)
706707
self.assertEqual(self.columns, columns)
707-
self.assertEqual(self.data, data)
708+
self.assertItemEqual(self.data, data)

0 commit comments

Comments
 (0)