app: add VMCollection.values()
Let it behave more like a dict()
This commit is contained in:
parent
7d476f8ba2
commit
7d25f1bf2b
@ -109,6 +109,11 @@ class VMCollection(object):
|
||||
self.refresh_cache()
|
||||
return self._vm_list.keys()
|
||||
|
||||
def values(self):
|
||||
'''Get list of VM objects.'''
|
||||
self.refresh_cache()
|
||||
return [self[name] for name in self._vm_list]
|
||||
|
||||
|
||||
class QubesBase(qubesadmin.base.PropertyHolder):
|
||||
'''Main Qubes application'''
|
||||
|
@ -80,6 +80,26 @@ class TC_00_VMCollection(qubesadmin.tests.QubesTestCase):
|
||||
del self.app.domains['test-vm']
|
||||
self.assertAllCalled()
|
||||
|
||||
def test_005_keys(self):
|
||||
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00test-vm class=AppVM state=Running\n' \
|
||||
b'test-vm2 class=AppVM state=Running\n'
|
||||
self.assertEqual(set(self.app.domains.keys()),
|
||||
set(['test-vm', 'test-vm2']))
|
||||
self.assertAllCalled()
|
||||
|
||||
def test_006_values(self):
|
||||
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00test-vm class=AppVM state=Running\n' \
|
||||
b'test-vm2 class=AppVM state=Running\n'
|
||||
values = self.app.domains.values()
|
||||
for obj in values:
|
||||
self.assertIsInstance(obj, qubesadmin.vm.AppVM)
|
||||
self.assertEqual(set([vm.name for vm in values]),
|
||||
set(['test-vm', 'test-vm2']))
|
||||
self.assertAllCalled()
|
||||
|
||||
|
||||
|
||||
class TC_10_QubesBase(qubesadmin.tests.QubesTestCase):
|
||||
def test_010_new_simple(self):
|
||||
|
Loading…
Reference in New Issue
Block a user