Add QubesNoSuchPropertyError exception, expect it on invalid property

It inherits from AttributeError, so standard handling should just work.
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-23 04:31:41 +02:00
parent fa66763628
commit de2f23b9fe
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 15 additions and 0 deletions

View File

@ -91,6 +91,11 @@ class QubesPropertyValueError(QubesValueError):
'''
class QubesNoSuchPropertyError(QubesException, AttributeError):
'''Requested property does not exist
'''
class QubesNotImplementedError(QubesException, NotImplementedError):
'''Thrown at user when some feature is not implemented'''

View File

@ -105,6 +105,16 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase):
self.assertEqual(self.vm.property_is_default('prop1'), True)
self.assertAllCalled()
def test_012_get_invalid(self):
self.app.expected_calls[
('test-vm', 'admin.vm.property.Get', 'invalid', None)] = \
b'2\x00QubesNoSuchPropertyError\x00\x00Invalid property ' \
b'\'invalid\' on test-vm\x00'
with self.assertRaises(qubesadmin.exc.QubesNoSuchPropertyError):
self.vm.invalid
self.assertFalse(hasattr(self.vm, 'invalid'))
self.assertAllCalled()
def test_020_set_str(self):
self.app.expected_calls[
('test-vm', 'admin.vm.property.Set', 'prop1', b'value')] = \