vm: change vm.updates_available to a 'updates-available' feature

This commit is contained in:
Marek Marczykowski-Górecki 2017-06-12 12:34:23 +02:00
parent caa03a9279
commit 37245acdcf
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 6 additions and 23 deletions

View File

@ -105,7 +105,7 @@ class QubesMiscAPI(qubes.api.AbstractQubesAPI):
if self.src.updateable:
# Just trust information from VM itself
self.src.updates_available = bool(update_count)
self.src.features['updates-available'] = bool(update_count)
self.app.save()
elif getattr(self.src, 'template', None) is not None:
# Hint about updates availability in template
@ -118,5 +118,6 @@ class QubesMiscAPI(qubes.api.AbstractQubesAPI):
# in the template - ignore info
if self.src.storage.outdated_volumes:
return
self.src.template.updates_available = bool(update_count)
self.src.template.features['updates-available'] = bool(
update_count)
self.app.save()

View File

@ -216,8 +216,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
self.assertIsNone(response)
self.assertEqual(self.src.mock_calls, [
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()])
def test_021_notify_updates_standalone2(self):
@ -226,8 +226,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
self.assertIsNone(response)
self.assertEqual(self.src.mock_calls, [
mock.call.updateable.__bool__(),
mock.call.features.__setitem__('updates-available', False),
])
self.assertEqual(self.src.updates_available, False)
self.assertEqual(self.app.mock_calls, [
mock.call.save()
])
@ -237,8 +237,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
with self.assertRaises(AssertionError):
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'')
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, [])
def test_023_notify_updates_invalid2(self):
@ -246,8 +244,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
with self.assertRaises(AssertionError):
self.call_mgmt_func(b'qubes.NotifyUpdates', payload=b'no updates')
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, [])
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, [
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, [])
def test_025_notify_updates_template_based(self):
@ -273,10 +266,8 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
self.assertIsNone(response)
self.assertEqual(self.src.mock_calls, [
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, [
mock.call.save()
])
@ -290,8 +281,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
self.assertEqual(self.src.mock_calls, [
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.assertEqual(self.app.mock_calls, [])
@ -304,8 +293,6 @@ class TC_00_API_Misc(qubes.tests.QubesTestCase):
self.assertEqual(self.src.mock_calls, [
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, [])

View File

@ -499,11 +499,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
default=(lambda self: self.app.default_dispvm),
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',
default=(lambda self: not hasattr(self, 'template')),
type=bool,