cinder list now prints dash '-' when data is None
cinder list used to print None when volume was created without name. Now it prints '-' dash when display_name is None Closes-Bug: #1422244 Change-Id: I195ccc37fe96dbb54a0460527fabf55146170bc7
This commit is contained in:
parent
f47f973d9b
commit
0f73c5fb8a
cinderclient
@ -121,6 +121,21 @@ class PrintListTestCase(test_utils.TestCase):
|
||||
| 1 | 2 |
|
||||
| 3 | 4 |
|
||||
+---+---+
|
||||
""", cso.read())
|
||||
|
||||
def test_print_list_with_None_data(self):
|
||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||
to_print = [Row(a=3, b=None), Row(a=1, b=2)]
|
||||
with CaptureStdout() as cso:
|
||||
utils.print_list(to_print, ['a', 'b'])
|
||||
# Output should be sorted by the first key (a)
|
||||
self.assertEqual("""\
|
||||
+---+---+
|
||||
| a | b |
|
||||
+---+---+
|
||||
| 1 | 2 |
|
||||
| 3 | - |
|
||||
+---+---+
|
||||
""", cso.read())
|
||||
|
||||
def test_print_list_with_list_sortby(self):
|
||||
|
@ -139,6 +139,8 @@ def print_list(objs, fields, formatters=None, sortby_index=0):
|
||||
data = o[field]
|
||||
else:
|
||||
data = getattr(o, field_name, '')
|
||||
if data is None:
|
||||
data = '-'
|
||||
row.append(data)
|
||||
pt.add_row(row)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user