2828def test_vm_manager (test_qapp ):
2929 dispatcher = qubesadmin .events .EventsDispatcher (test_qapp )
3030 vm_manager = VMManager (test_qapp , dispatcher )
31+ vm_name = "test-vm"
32+ template_name = "fedora-36"
3133
32- entry_test = vm_manager .load_vm_from_name ("test-vm" )
34+ entry_test = vm_manager .load_vm_from_name (vm_name )
3335 assert entry_test
34- assert entry_test .vm_name == "test-vm"
36+ assert entry_test .vm_name == vm_name
3537 assert entry_test .vm_icon_name == "appvm-green"
36- entry_template = vm_manager .load_vm_from_name ("fedora-36" )
38+ entry_template = vm_manager .load_vm_from_name (template_name )
3739 assert entry_template
3840 assert not entry_template .has_network
41+ assert not entry_template .internal
3942 assert not entry_test .is_dispvm_template
4043 assert not entry_test .service_vm
44+ assert not entry_test .internal
4145
4246 test_qapp ._qubes ["fedora-36" ].properties ["netvm" ] = Property (
4347 "sys-firewall" , "vm" , False
@@ -53,44 +57,62 @@ def test_vm_manager(test_qapp):
5357 )
5458 assert entry_template .has_network
5559
56- test_qapp ._qubes ["test-vm" ].properties ["label" ] = Property (
60+ test_qapp ._qubes [vm_name ].properties ["label" ] = Property (
5761 "red" , "label" , False
5862 )
59- test_qapp ._qubes ["test-vm" ].properties ["icon" ] = Property (
63+ test_qapp ._qubes [vm_name ].properties ["icon" ] = Property (
6064 "appvm-red" , "str" , False
6165 )
62- test_qapp ._qubes ["test-vm" ].update_calls ()
63-
66+ test_qapp ._qubes [vm_name ].update_calls ()
6467 vm_manager ._update_domain_property (
65- "test-vm" ,
68+ vm_name ,
6669 "property-set:label" ,
6770 name = "label" ,
6871 newvalue = "red" ,
6972 oldvalue = "blue" ,
7073 )
7174 assert entry_test .vm_icon_name == "appvm-red"
7275
73- test_qapp ._qubes ["test-vm" ].properties ["template_for_dispvms" ] = Property (
76+ test_qapp ._qubes [vm_name ].properties ["template_for_dispvms" ] = Property (
7477 "True" , "bool" , False
7578 )
76- test_qapp ._qubes ["test-vm" ].update_calls ()
77-
79+ test_qapp ._qubes [vm_name ].update_calls ()
7880 vm_manager ._update_domain_property (
79- "test-vm" ,
81+ vm_name ,
8082 "property-set:template_for_dispvms" ,
8183 name = "template_for_dispvms" ,
8284 newvalue = True ,
8385 )
8486 assert entry_test .is_dispvm_template
8587
86- test_qapp ._qubes ["test-vm" ].features ["servicevm" ] = 1
87- test_qapp ._qubes ["test-vm" ].update_calls ()
88-
88+ test_qapp ._qubes [vm_name ].features ["servicevm" ] = 1
89+ test_qapp ._qubes [vm_name ].update_calls ()
8990 vm_manager ._update_domain_feature (
90- "test-vm" , "feature-set:servicevm" , feature = "servicevm" , value = 1
91+ vm_name , "feature-set:servicevm" , feature = "servicevm" , value = 1
9192 )
9293 assert entry_test .service_vm
9394
95+ test_qapp ._qubes [vm_name ].features ["internal" ] = 1
96+ test_qapp ._qubes [vm_name ].update_calls ()
97+ vm_manager ._update_domain_feature (
98+ vm_name , "feature-set:internal" , feature = "internal" , value = 1
99+ )
100+ assert entry_test .internal
101+
102+ del test_qapp ._qubes [vm_name ].features ["internal" ]
103+ test_qapp ._qubes [vm_name ].update_calls ()
104+ vm_manager ._update_domain_feature (
105+ vm_name , "feature-delete:internal" , feature = "internal"
106+ )
107+ assert not entry_test .internal
108+
109+ test_qapp ._qubes [template_name ].features ["internal" ] = 1
110+ test_qapp ._qubes [vm_name ].update_calls ()
111+ vm_manager ._update_domain_feature (
112+ vm_name , "feature-set:internal" , feature = "internal" , value = 1
113+ )
114+ assert entry_test .internal
115+
94116
95117def test_filter (test_qapp ):
96118 dispatcher = qubesadmin .events .EventsDispatcher (test_qapp )
0 commit comments