vm: change vm.updates_available to a 'updates-available' feature
This commit is contained in:
parent
caa03a9279
commit
37245acdcf
@ -105,7 +105,7 @@ class QubesMiscAPI(qubes.api.AbstractQubesAPI):
|
|||||||
|
|
||||||
if self.src.updateable:
|
if self.src.updateable:
|
||||||
# Just trust information from VM itself
|
# Just trust information from VM itself
|
||||||
self.src.updates_available = bool(update_count)
|
self.src.features['updates-available'] = bool(update_count)
|
||||||
self.app.save()
|
self.app.save()
|
||||||
elif getattr(self.src, 'template', None) is not None:
|
elif getattr(self.src, 'template', None) is not None:
|
||||||
# Hint about updates availability in template
|
# Hint about updates availability in template
|
||||||
@ -118,5 +118,6 @@ class QubesMiscAPI(qubes.api.AbstractQubesAPI):
|
|||||||
# in the template - ignore info
|
# in the template - ignore info
|
||||||
if self.src.storage.outdated_volumes:
|
if self.src.storage.outdated_volumes:
|
||||||
return
|
return
|
||||||
self.src.template.updates_available = bool(update_count)
|
self.src.template.features['updates-available'] = bool(
|
||||||
|
update_count)
|
||||||
self.app.save()
|
self.app.save()
|
||||||
|
@ -216,8 +216,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertIsNone(response)
|
self.assertIsNone(response)
|
||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.updateable.__bool__(),
|
mock.call.updateable.__bool__(),
|
||||||
|
mock.call.features.__setitem__('updates-available', True),
|
||||||
])
|
])
|
||||||
self.assertEqual(self.src.updates_available, True)
|
|
||||||
self.assertEqual(self.app.mock_calls, [mock.call.save()])
|
self.assertEqual(self.app.mock_calls, [mock.call.save()])
|
||||||
|
|
||||||
def test_021_notify_updates_standalone2(self):
|
def test_021_notify_updates_standalone2(self):
|
||||||
@ -226,8 +226,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertIsNone(response)
|
self.assertIsNone(response)
|
||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.updateable.__bool__(),
|
mock.call.updateable.__bool__(),
|
||||||
|
mock.call.features.__setitem__('updates-available', False),
|
||||||
])
|
])
|
||||||
self.assertEqual(self.src.updates_available, False)
|
|
||||||
self.assertEqual(self.app.mock_calls, [
|
self.assertEqual(self.app.mock_calls, [
|
||||||
mock.call.save()
|
mock.call.save()
|
||||||
])
|
])
|
||||||
@ -237,8 +237,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'')
|
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'')
|
||||||
self.assertEqual(self.src.mock_calls, [])
|
self.assertEqual(self.src.mock_calls, [])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
|
||||||
self.assertEqual(self.app.mock_calls, [])
|
self.assertEqual(self.app.mock_calls, [])
|
||||||
|
|
||||||
def test_023_notify_updates_invalid2(self):
|
def test_023_notify_updates_invalid2(self):
|
||||||
@ -246,8 +244,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'no updates')
|
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'no updates')
|
||||||
self.assertEqual(self.src.mock_calls, [])
|
self.assertEqual(self.src.mock_calls, [])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
|
||||||
self.assertEqual(self.app.mock_calls, [])
|
self.assertEqual(self.app.mock_calls, [])
|
||||||
|
|
||||||
def test_024_notify_updates_template_based_no_updates(self):
|
def test_024_notify_updates_template_based_no_updates(self):
|
||||||
@ -259,9 +255,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.template.is_running(),
|
mock.call.template.is_running(),
|
||||||
])
|
])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.template.updates_available, mock.Mock)
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
|
||||||
self.assertEqual(self.app.mock_calls, [])
|
self.assertEqual(self.app.mock_calls, [])
|
||||||
|
|
||||||
def test_025_notify_updates_template_based(self):
|
def test_025_notify_updates_template_based(self):
|
||||||
@ -273,10 +266,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertIsNone(response)
|
self.assertIsNone(response)
|
||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.template.is_running(),
|
mock.call.template.is_running(),
|
||||||
|
mock.call.template.features.__setitem__('updates-available', True),
|
||||||
])
|
])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
|
||||||
self.assertEqual(self.src.template.updates_available, True)
|
|
||||||
self.assertEqual(self.app.mock_calls, [
|
self.assertEqual(self.app.mock_calls, [
|
||||||
mock.call.save()
|
mock.call.save()
|
||||||
])
|
])
|
||||||
@ -290,8 +281,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.template.is_running(),
|
mock.call.template.is_running(),
|
||||||
])
|
])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
|
||||||
self.assertIsInstance(self.src.template.updates_available, mock.Mock)
|
self.assertIsInstance(self.src.template.updates_available, mock.Mock)
|
||||||
self.assertEqual(self.app.mock_calls, [])
|
self.assertEqual(self.app.mock_calls, [])
|
||||||
|
|
||||||
@ -304,8 +293,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
|
|||||||
self.assertEqual(self.src.mock_calls, [
|
self.assertEqual(self.src.mock_calls, [
|
||||||
mock.call.template.is_running(),
|
mock.call.template.is_running(),
|
||||||
])
|
])
|
||||||
# not set property returns Mock()
|
|
||||||
self.assertIsInstance(self.src.template.updates_available, mock.Mock)
|
|
||||||
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
self.assertIsInstance(self.src.updates_available, mock.Mock)
|
||||||
self.assertEqual(self.app.mock_calls, [])
|
self.assertEqual(self.app.mock_calls, [])
|
||||||
|
|
||||||
|
@ -499,11 +499,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
default=(lambda self: self.app.default_dispvm),
|
default=(lambda self: self.app.default_dispvm),
|
||||||
doc='Default VM to be used as Disposable VM for service calls.')
|
doc='Default VM to be used as Disposable VM for service calls.')
|
||||||
|
|
||||||
updates_available = qubes.property('updates_available',
|
|
||||||
type=bool,
|
|
||||||
default=False,
|
|
||||||
doc='If updates are pending to be installed')
|
|
||||||
|
|
||||||
updateable = qubes.property('updateable',
|
updateable = qubes.property('updateable',
|
||||||
default=(lambda self: not hasattr(self, 'template')),
|
default=(lambda self: not hasattr(self, 'template')),
|
||||||
type=bool,
|
type=bool,
|
||||||
|
Loading…
Reference in New Issue
Block a user