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:
yatin karel 2015-03-16 23:26:12 +05:30
parent f47f973d9b
commit 0f73c5fb8a
2 changed files with 17 additions and 0 deletions

View File

@ -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):

View File

@ -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)