From 45ac1c719e7a15dee3eeb70012fbef6340e9da1d Mon Sep 17 00:00:00 2001 From: Mohammed Alkindi Date: Fri, 28 Aug 2026 20:57:27 +0400 Subject: [PATCH] Mock check_winpe in test_driver_wim and correct its call expectations. The test read the real registry, so its branch depended on the host. Its expectations also mixed WINPE_DISM for mount and unmount with SYS_PNPUTIL for add-driver, which _ProcessWim cannot emit in one run because both derive from the same lru_cache-wrapped check_winpe result. Mocks the probe to False and matches the mount and unmount constants to it. test_driver_wim_winpe already covers the True branch the same way. --- glazier/lib/actions/drivers_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/glazier/lib/actions/drivers_test.py b/glazier/lib/actions/drivers_test.py index 82ba2093..9d374706 100644 --- a/glazier/lib/actions/drivers_test.py +++ b/glazier/lib/actions/drivers_test.py @@ -24,6 +24,7 @@ class DriversTest(test_utils.GlazierTestCase): + @mock.patch.object(drivers.winpe, 'check_winpe', autospec=True) @mock.patch.object(BuildInfo, 'ReleasePath') @mock.patch.object(BuildInfo, 'Branch') @mock.patch('glazier.lib.download.Download.VerifyShaHash', autospec=True) @@ -32,7 +33,7 @@ class DriversTest(test_utils.GlazierTestCase): @mock.patch.object(drivers.file_util, 'CreateDirectories', autospec=True) def test_driver_wim(self, mock_createdirectories, mock_execute_binary, mock_downloadfile, mock_verifyshahash, mock_branch, - mock_releasepath): + mock_releasepath, mock_check_winpe): bi = BuildInfo() @@ -49,6 +50,7 @@ def test_driver_wim(self, mock_createdirectories, mock_execute_binary, } mock_branch.return_value = 'stable' mock_releasepath.return_value = '/' + mock_check_winpe.return_value = False # Success dw = drivers.DriverWIM(conf['data']['driver'], bi) @@ -62,7 +64,7 @@ def test_driver_wim(self, mock_createdirectories, mock_execute_binary, cache = drivers.constants.SYS_CACHE mock_execute_binary.assert_has_calls([ mock.call( - drivers.constants.WINPE_DISM, + drivers.constants.SYS_DISM, [ '/Mount-Image', f'/ImageFile:{local}', @@ -78,7 +80,7 @@ def test_driver_wim(self, mock_createdirectories, mock_execute_binary, shell=False, ), mock.call( - drivers.constants.WINPE_DISM, + drivers.constants.SYS_DISM, ['/Unmount-Image', f'/MountDir:{cache}\\Drivers\\', '/Discard'], shell=False, ),