22#
33# The Qubes OS Project, https://www.qubes-os.org
44#
5- # Copyright (C) 2026
5+ # Copyright (C) 2025 Jayant Sankar <jayant@example.com>
66#
77# This program is free software; you can redistribute it and/or
88# modify it under the terms of the GNU General Public License
99# as published by the Free Software Foundation; either version 2
1010# of the License, or (at your option) any later version.
1111#
12+ # This program is distributed in the hope that it will be useful,
13+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ # GNU General Public License for more details.
16+ #
17+ # You should have received a copy of the GNU General Public License
18+ # along with this program; if not, write to the Free Software
19+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20+ # USA.
1221from unittest .mock import Mock , patch
1322
1423from vmupdate .qube_connection import QubeConnection
1524
1625
17- @patch ("vmupdate.qube_connection.wait_for_domain_shutdown" )
18- @patch ("vmupdate.qube_connection.asyncio.run" )
19- def test_wait_for_shutdown_when_vm_started_by_update (_arun , wait_shutdown ):
26+ @patch ("vmupdate.vmupdate.shutdown_domains" )
27+ def test_wait_for_shutdown_when_vm_started_by_update (shutdown_domains ):
2028 vm = Mock ()
2129 vm .name = "hvm1"
2230 vm .is_running .side_effect = [False , True ]
@@ -30,14 +38,12 @@ def test_wait_for_shutdown_when_vm_started_by_update(_arun, wait_shutdown):
3038 show_progress = False , status_notifier = status_notifier ):
3139 pass
3240
33- vm .shutdown .assert_called_once_with ()
34- wait_shutdown .assert_called_once_with ([vm ])
35- _arun .assert_called_once ()
41+ shutdown_domains .assert_called_once_with ([vm ], logger )
42+ vm .shutdown .assert_not_called ()
3643
3744
38- @patch ("vmupdate.qube_connection.wait_for_domain_shutdown" )
39- @patch ("vmupdate.qube_connection.asyncio.run" )
40- def test_do_not_wait_for_shutdown_without_assigned_pci (_arun , wait_shutdown ):
45+ @patch ("vmupdate.vmupdate.shutdown_domains" )
46+ def test_do_not_wait_for_shutdown_without_assigned_pci (shutdown_domains ):
4147 vm = Mock ()
4248 vm .name = "hvm2"
4349 vm .is_running .side_effect = [False , True ]
@@ -52,13 +58,11 @@ def test_do_not_wait_for_shutdown_without_assigned_pci(_arun, wait_shutdown):
5258 pass
5359
5460 vm .shutdown .assert_called_once_with ()
55- wait_shutdown .assert_not_called ()
56- _arun .assert_not_called ()
61+ shutdown_domains .assert_not_called ()
5762
5863
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 ):
64+ @patch ("vmupdate.vmupdate.shutdown_domains" )
65+ def test_do_not_shutdown_if_vm_was_already_running (shutdown_domains ):
6266 vm = Mock ()
6367 vm .name = "hvm3"
6468 vm .is_running .return_value = True
@@ -73,5 +77,4 @@ def test_do_not_shutdown_if_vm_was_already_running(_arun, wait_shutdown):
7377 pass
7478
7579 vm .shutdown .assert_not_called ()
76- wait_shutdown .assert_not_called ()
77- _arun .assert_not_called ()
80+ shutdown_domains .assert_not_called ()
0 commit comments