@@ -20,6 +20,8 @@ def test_wait_for_shutdown_when_vm_started_by_update(_arun, wait_shutdown):
2020 vm = Mock ()
2121 vm .name = "hvm1"
2222 vm .is_running .side_effect = [False , True ]
23+ vm .devices = {'pci' : Mock ()}
24+ vm .devices ['pci' ].get_assigned_devices .return_value = ["00_1f.2" ]
2325 status_notifier = Mock ()
2426 logger = Mock ()
2527
@@ -35,10 +37,33 @@ def test_wait_for_shutdown_when_vm_started_by_update(_arun, wait_shutdown):
3537
3638@patch ("vmupdate.qube_connection.wait_for_domain_shutdown" )
3739@patch ("vmupdate.qube_connection.asyncio.run" )
38- def test_do_not_shutdown_if_vm_was_already_running (_arun , wait_shutdown ):
40+ def test_do_not_wait_for_shutdown_without_assigned_pci (_arun , wait_shutdown ):
3941 vm = Mock ()
4042 vm .name = "hvm2"
43+ vm .is_running .side_effect = [False , True ]
44+ vm .devices = {'pci' : Mock ()}
45+ vm .devices ['pci' ].get_assigned_devices .return_value = []
46+ status_notifier = Mock ()
47+ logger = Mock ()
48+
49+ with QubeConnection (
50+ vm , "/tmp/qubes-update" , cleanup = False , logger = logger ,
51+ show_progress = False , status_notifier = status_notifier ):
52+ pass
53+
54+ vm .shutdown .assert_called_once_with ()
55+ wait_shutdown .assert_not_called ()
56+ _arun .assert_not_called ()
57+
58+
59+ @patch ("vmupdate.qube_connection.wait_for_domain_shutdown" )
60+ @patch ("vmupdate.qube_connection.asyncio.run" )
61+ def test_do_not_shutdown_if_vm_was_already_running (_arun , wait_shutdown ):
62+ vm = Mock ()
63+ vm .name = "hvm3"
4164 vm .is_running .return_value = True
65+ vm .devices = {'pci' : Mock ()}
66+ vm .devices ['pci' ].get_assigned_devices .return_value = ["00_1f.2" ]
4267 status_notifier = Mock ()
4368 logger = Mock ()
4469
0 commit comments