def test_install_error_other(self): """ test install function on other unknown error """ mock_retcode = MagicMock(return_value=1234) path = "C:\\KB123456.msu" with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ["wusa.exe", path, "/quiet", "/norestart"], ignore_retcode=True) self.assertEqual("Unknown error: 1234", excinfo.exception.strerror)
def test_install_error_87(self): ''' test install function when error 87 returned ''' mock_retcode = MagicMock(return_value=87) path = 'C:\\KB123456.msu' with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ['wusa.exe', path, '/quiet', '/norestart'], ignore_retcode=True) self.assertEqual('Unknown error', excinfo.exception.strerror)
def test_install_already_installed(self): ''' test install function when KB already installed ''' mock_retcode = MagicMock(return_value=2359302) path = 'C:\\KB123456.msu' name = 'KB123456.msu' with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ['wusa.exe', path, '/quiet', '/norestart'], ignore_retcode=True) self.assertEqual('{0} is already installed'.format(name), excinfo.exception.strerror)
def test_install_error_87(self): """ test install function when error 87 returned """ retcode = 87 mock_retcode = MagicMock(return_value=retcode) path = "C:\\KB123456.msu" with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ["wusa.exe", path, "/quiet", "/norestart"], ignore_retcode=True) self.assertEqual( "Unknown error. Additional info follows:\n\n{}".format(retcode), excinfo.exception.strerror, )
def test_install_reboot_needed(self): ''' test install function when KB need a reboot ''' retcode = 3010 mock_retcode = MagicMock(return_value=retcode) path = 'C:\\KB123456.msu' name = 'KB123456.msu' with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ['wusa.exe', path, '/quiet', '/norestart'], ignore_retcode=True) self.assertEqual( '{0} correctly installed but server reboot is needed to complete installation. Additional info follows:\n\n{1}' .format(name, retcode), excinfo.exception.strerror)
def test_install_reboot_needed(self): """ test install function when KB need a reboot """ retcode = 3010 mock_retcode = MagicMock(return_value=retcode) path = "C:\\KB123456.msu" name = "KB123456.msu" with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ["wusa.exe", path, "/quiet", "/norestart"], ignore_retcode=True) self.assertEqual( "{} correctly installed but server reboot is needed to complete installation. Additional info follows:\n\n{}" .format(name, retcode), excinfo.exception.strerror, )
def test_install_already_installed(self): """ test install function when KB already installed """ retcode = 2359302 mock_retcode = MagicMock(return_value=retcode) path = "C:\\KB123456.msu" name = "KB123456.msu" with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}): with self.assertRaises(CommandExecutionError) as excinfo: win_wusa.install(path) mock_retcode.assert_called_once_with( ["wusa.exe", path, "/quiet", "/norestart"], ignore_retcode=True) self.assertEqual( "{0} is already installed. Additional info follows:\n\n{1}".format( name, retcode), excinfo.exception.strerror, )
def test_install_restart(self): ''' test install function with restart=True ''' mock_retcode = MagicMock(return_value=0) path = 'C:\\KB123456.msu' with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}): self.assertTrue(win_wusa.install(path, restart=True)) mock_retcode.assert_called_once_with( ['wusa.exe', path, '/quiet', '/forcerestart'], ignore_retcode=True)
def test_install_restart(self): """ test install function with restart=True """ mock_retcode = MagicMock(return_value=0) path = "C:\\KB123456.msu" with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}): self.assertTrue(win_wusa.install(path, restart=True)) mock_retcode.assert_called_once_with( ["wusa.exe", path, "/quiet", "/forcerestart"], ignore_retcode=True)