Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 77 additions & 44 deletions qubes_menu/tests/test_vmmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,100 @@
def test_vm_manager(test_qapp):
dispatcher = qubesadmin.events.EventsDispatcher(test_qapp)
vm_manager = VMManager(test_qapp, dispatcher)
vm_name = "test-vm"
template_name = "fedora-36"

entry_test = vm_manager.load_vm_from_name('test-vm')
entry_test = vm_manager.load_vm_from_name(vm_name)
assert entry_test
assert entry_test.vm_name == 'test-vm'
assert entry_test.vm_icon_name == 'appvm-green'
entry_template = vm_manager.load_vm_from_name('fedora-36')
assert entry_test.vm_name == vm_name
assert entry_test.vm_icon_name == "appvm-green"
entry_template = vm_manager.load_vm_from_name(template_name)
assert entry_template
assert not entry_template.has_network
assert not entry_template.internal
assert not entry_test.is_dispvm_template
assert not entry_test.service_vm

test_qapp._qubes['fedora-36'].properties['netvm'] = \
Property('sys-firewall', 'vm', False)
test_qapp._qubes['fedora-36'].update_calls()

vm_manager._update_domain_property('fedora-36',
'property-set:netvm', name='netvm',
newvalue='sys-firewall',
oldvalue=None)
assert not entry_test.internal

test_qapp._qubes["fedora-36"].properties["netvm"] = Property(
"sys-firewall", "vm", False
)
test_qapp._qubes["fedora-36"].update_calls()

vm_manager._update_domain_property(
"fedora-36",
"property-set:netvm",
name="netvm",
newvalue="sys-firewall",
oldvalue=None,
)
assert entry_template.has_network

test_qapp._qubes['test-vm'].properties['label'] = \
Property('red', 'label', False)
test_qapp._qubes['test-vm'].properties['icon'] = \
Property('appvm-red', 'str', False)
test_qapp._qubes['test-vm'].update_calls()

vm_manager._update_domain_property('test-vm',
'property-set:label', name='label',
newvalue='red',
oldvalue='blue')
assert entry_test.vm_icon_name == 'appvm-red'

test_qapp._qubes['test-vm'].properties['template_for_dispvms'] = \
Property('True', 'bool', False)
test_qapp._qubes['test-vm'].update_calls()

vm_manager._update_domain_property('test-vm',
'property-set:template_for_dispvms',
name='template_for_dispvms',
newvalue=True)
test_qapp._qubes[vm_name].properties["label"] = Property(
"red", "label", False
)
test_qapp._qubes[vm_name].properties["icon"] = Property(
"appvm-red", "str", False
)
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_property(
vm_name,
"property-set:label",
name="label",
newvalue="red",
oldvalue="blue",
)
assert entry_test.vm_icon_name == "appvm-red"

test_qapp._qubes[vm_name].properties["template_for_dispvms"] = Property(
"True", "bool", False
)
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_property(
vm_name,
"property-set:template_for_dispvms",
name="template_for_dispvms",
newvalue=True,
)
assert entry_test.is_dispvm_template

test_qapp._qubes['test-vm'].features['servicevm'] = 1
test_qapp._qubes['test-vm'].update_calls()

vm_manager._update_domain_feature('test-vm',
'feature-set:servicevm',
feature='servicevm',
value=1)
test_qapp._qubes[vm_name].features["servicevm"] = 1
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_feature(
vm_name, "feature-set:servicevm", feature="servicevm", value=1
)
assert entry_test.service_vm

test_qapp._qubes[vm_name].features["internal"] = 1
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_feature(
vm_name, "feature-set:internal", feature="internal", value=1
)
assert entry_test.internal

del test_qapp._qubes[vm_name].features["internal"]
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_feature(
vm_name, "feature-delete:internal", feature="internal"
)
assert not entry_test.internal

test_qapp._qubes[template_name].features["internal"] = 1
test_qapp._qubes[vm_name].update_calls()
vm_manager._update_domain_feature(
vm_name, "feature-set:internal", feature="internal", value=1
)
assert entry_test.internal


def test_filter(test_qapp):
dispatcher = qubesadmin.events.EventsDispatcher(test_qapp)
vm_manager = VMManager(test_qapp, dispatcher)

entry_test = vm_manager.load_vm_from_name('test-vm')
entry_template = vm_manager.load_vm_from_name('fedora-36')
entry_service = vm_manager.load_vm_from_name('sys-net')
entry_dvm_template = vm_manager.load_vm_from_name('default-dvm')
entry_test = vm_manager.load_vm_from_name("test-vm")
entry_template = vm_manager.load_vm_from_name("fedora-36")
entry_service = vm_manager.load_vm_from_name("sys-net")
entry_dvm_template = vm_manager.load_vm_from_name("default-dvm")
assert entry_test
assert entry_template
assert entry_service
Expand Down
Loading