Merge "Ensure that the diagnostics are user friendly"
This commit is contained in:
commit
1a20d2964d
@ -125,6 +125,31 @@ class _FakeResult(object):
|
||||
|
||||
|
||||
class PrintResultTestCase(test_utils.TestCase):
|
||||
@mock.patch('sys.stdout', six.StringIO())
|
||||
def test_print_dict(self):
|
||||
dict = {'key': 'value'}
|
||||
utils.print_dict(dict)
|
||||
self.assertEqual(sys.stdout.getvalue(),
|
||||
'+----------+-------+\n'
|
||||
'| Property | Value |\n'
|
||||
'+----------+-------+\n'
|
||||
'| key | value |\n'
|
||||
'+----------+-------+\n')
|
||||
|
||||
@mock.patch('sys.stdout', six.StringIO())
|
||||
def test_print_dict_wrap(self):
|
||||
dict = {'key1': 'not wrapped',
|
||||
'key2': 'this will be wrapped'}
|
||||
utils.print_dict(dict, wrap=16)
|
||||
self.assertEqual(sys.stdout.getvalue(),
|
||||
'+----------+--------------+\n'
|
||||
'| Property | Value |\n'
|
||||
'+----------+--------------+\n'
|
||||
'| key1 | not wrapped |\n'
|
||||
'| key2 | this will be |\n'
|
||||
'| | wrapped |\n'
|
||||
'+----------+--------------+\n')
|
||||
|
||||
@mock.patch('sys.stdout', six.StringIO())
|
||||
def test_print_list_sort_by_str(self):
|
||||
objs = [_FakeResult("k1", 1),
|
||||
|
@ -1372,7 +1372,7 @@ def do_unshelve(cs, args):
|
||||
def do_diagnostics(cs, args):
|
||||
"""Retrieve server diagnostics."""
|
||||
server = _find_server(cs, args.server)
|
||||
utils.print_dict(cs.servers.diagnostics(server)[1])
|
||||
utils.print_dict(cs.servers.diagnostics(server)[1], wrap=80)
|
||||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
|
@ -1210,7 +1210,7 @@ def do_unrescue(cs, args):
|
||||
def do_diagnostics(cs, args):
|
||||
"""Retrieve server diagnostics."""
|
||||
server = _find_server(cs, args.server)
|
||||
utils.print_dict(cs.servers.diagnostics(server)[1])
|
||||
utils.print_dict(cs.servers.diagnostics(server)[1], wrap=80)
|
||||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
|
Loading…
Reference in New Issue
Block a user