tools/qvm-ls: fix handling columns with underscore

Mangling column type was inconsistent, resulting in
KeyError('VIRT_MODE').
This commit is contained in:
Marek Marczykowski-Górecki 2017-12-29 00:56:16 +01:00
parent c82d5b0a73
commit 917df5a8c5
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 13 additions and 1 deletions

View File

@ -86,6 +86,17 @@ class TC_50_List(qubesadmin.tests.QubesTestCase):
'dom0 Running TestVM black - -\n'
'test-vm Running TestVM green template sys-net\n')
def test_101_list_with_underscore(self):
app = TestApp()
app.domains['test-vm'].virt_mode = 'pv'
app.domains['test-vm'].label = 'green'
app.domains['dom0'].label = 'black'
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
qubesadmin.tools.qvm_ls.main(['-O', 'name,virt_mode,class'], app=app)
self.assertEqual(stdout.getvalue(),
'NAME VIRT-MODE CLASS\n'
'dom0 - TestVM\n'
'test-vm pv TestVM\n')
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
def test_100_list_with_status(self):

View File

@ -389,7 +389,8 @@ class Table(object):
'''
def __init__(self, app, colnames, spinner, raw_data=False):
self.app = app
self.columns = tuple(Column.columns[col.upper()] for col in colnames)
self.columns = tuple(Column.columns[col.upper().replace('_', '-')]
for col in colnames)
self.spinner = spinner
self.raw_data = raw_data