parent
278243d7dc
commit
027df9567c
@ -464,6 +464,20 @@ class QubesMgmt(AbstractQubesMgmt):
|
||||
|
||||
return label.color
|
||||
|
||||
@api('mgmt.label.Index', no_payload=True)
|
||||
@asyncio.coroutine
|
||||
def label_index(self):
|
||||
assert self.dest.name == 'dom0'
|
||||
|
||||
try:
|
||||
label = self.app.get_label(self.arg)
|
||||
except KeyError:
|
||||
raise qubes.exc.QubesValueError
|
||||
|
||||
self.fire_event_for_permission(label=label)
|
||||
|
||||
return str(label.index)
|
||||
|
||||
@api('mgmt.label.Create')
|
||||
@asyncio.coroutine
|
||||
def label_create(self, untrusted_payload):
|
||||
|
@ -681,6 +681,15 @@ class TC_00_VMs(MgmtTestCase):
|
||||
[unittest.mock.call('red')])
|
||||
self.assertFalse(self.app.save.called)
|
||||
|
||||
def test_195_label_index(self):
|
||||
self.app.get_label = unittest.mock.Mock()
|
||||
self.app.get_label.configure_mock(**{'return_value.index': 1})
|
||||
value = self.call_mgmt_func(b'mgmt.label.Index', b'dom0', b'red')
|
||||
self.assertEqual(value, '1')
|
||||
self.assertEqual(self.app.get_label.mock_calls,
|
||||
[unittest.mock.call('red')])
|
||||
self.assertFalse(self.app.save.called)
|
||||
|
||||
def test_200_label_create(self):
|
||||
self.app.get_label = unittest.mock.Mock()
|
||||
self.app.get_label.side_effect=KeyError
|
||||
|
Loading…
Reference in New Issue
Block a user