features: serialize True as '1'

Do the same as core-admin code.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-28 13:56:05 +02:00
parent 416ee0bd22
commit 0fae70be53
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
4 changed files with 8 additions and 5 deletions

View File

@ -42,9 +42,10 @@ class Features(object):
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Remove', key)
def __setitem__(self, key, value):
if value is False:
if isinstance(value, bool):
# False value needs to be serialized as empty string
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key, b'')
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key,
b'1' if value else b'')
else:
self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key,
str(value).encode())

View File

@ -1354,6 +1354,8 @@ class TC_10_BackupCompatibility(qubesadmin.tests.backup.BackupTestCase):
for feature, value in vm['features'].items():
if value is False:
value = ''
elif value is True:
value = '1'
self.app.expected_calls[
(name, 'admin.vm.feature.Set', feature,
str(value).encode())] = b'0\0'

View File

@ -78,7 +78,7 @@ class TC_00_Features(qubesadmin.tests.QubesTestCase):
def test_021_set_bool(self):
self.app.expected_calls[
('test-vm', 'admin.vm.feature.Set', 'feature1', b'True')] = \
('test-vm', 'admin.vm.feature.Set', 'feature1', b'1')] = \
b'0\0'
self.vm.features['feature1'] = True
self.assertAllCalled()

View File

@ -243,7 +243,7 @@ class TC_00_qvm_template_postprocess(qubesadmin.tests.QubesTestCase):
self.app.expected_calls[
('test-vm', 'admin.vm.property.Reset', 'netvm', None)] = b'0\0'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.Set', 'qrexec', b'True')] = b'0\0'
('test-vm', 'admin.vm.feature.Set', 'qrexec', b'1')] = b'0\0'
self.app.expected_calls[
('test-vm', 'admin.vm.Start', None, None)] = b'0\0'
self.app.expected_calls[
@ -293,7 +293,7 @@ class TC_00_qvm_template_postprocess(qubesadmin.tests.QubesTestCase):
self.app.expected_calls[
('test-vm', 'admin.vm.property.Reset', 'netvm', None)] = b'0\0'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.Set', 'qrexec', b'True')] = b'0\0'
('test-vm', 'admin.vm.feature.Set', 'qrexec', b'1')] = b'0\0'
self.app.expected_calls[
('test-vm', 'admin.vm.Start', None, None)] = b'0\0'
self.app.expected_calls[