Beispiel #1
0
 def test_uninstall_already_uninstalled(self):
     """
     test uninstall function when KB already uninstalled
     """
     retcode = 2359303
     mock_retcode = MagicMock(return_value=retcode)
     kb = "KB123456"
     with patch.dict(win_wusa.__salt__, {"cmd.retcode": mock_retcode}):
         with self.assertRaises(CommandExecutionError) as excinfo:
             win_wusa.uninstall(kb)
     mock_retcode.assert_called_once_with(
         [
             "wusa.exe",
             "/uninstall",
             "/quiet",
             "/kb:{}".format(kb[2:]),
             "/norestart",
         ],
         ignore_retcode=True,
     )
     self.assertEqual(
         "{} not installed. Additional info follows:\n\n{}".format(
             kb, retcode),
         excinfo.exception.strerror,
     )
Beispiel #2
0
 def test_uninstall_path_error_other(self):
     '''
     test uninstall function with unknown error
     '''
     mock_retcode = MagicMock(return_value=1234)
     path = 'C:\\KB123456.msu'
     with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}), \
             patch("os.path.exists", MagicMock(return_value=True)), \
             self.assertRaises(CommandExecutionError) as excinfo:
         win_wusa.uninstall(path)
     mock_retcode.assert_called_once_with(
         ['wusa.exe', '/uninstall', '/quiet', path, '/norestart'],
         ignore_retcode=True)
     self.assertEqual('Unknown error: 1234', excinfo.exception.strerror)
Beispiel #3
0
 def test_uninstall_already_uninstalled(self):
     '''
     test uninstall function when KB already uninstalled
     '''
     mock_retcode = MagicMock(return_value=2359303)
     kb = 'KB123456'
     with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}):
         with self.assertRaises(CommandExecutionError) as excinfo:
             win_wusa.uninstall(kb)
     mock_retcode.assert_called_once_with(
         ['wusa.exe', '/uninstall', '/quiet', '/kb:{0}'.format(kb[2:]), '/norestart'],
         ignore_retcode=True)
     self.assertEqual('{0} not installed'.format(kb),
                      excinfo.exception.strerror)
Beispiel #4
0
 def test_uninstall_path_error_other(self):
     """
     test uninstall function with unknown error
     """
     mock_retcode = MagicMock(return_value=1234)
     path = "C:\\KB123456.msu"
     with patch.dict(win_wusa.__salt__,
                     {"cmd.retcode": mock_retcode}), patch(
                         "os.path.exists",
                         MagicMock(return_value=True)), self.assertRaises(
                             CommandExecutionError) as excinfo:
         win_wusa.uninstall(path)
     mock_retcode.assert_called_once_with(
         ["wusa.exe", "/uninstall", "/quiet", path, "/norestart"],
         ignore_retcode=True,
     )
     self.assertEqual("Unknown error: 1234", excinfo.exception.strerror)
Beispiel #5
0
 def test_uninstall_path_restart(self):
     '''
     test uninstall function with full path and restart=True
     '''
     mock_retcode = MagicMock(return_value=0)
     path = 'C:\\KB123456.msu'
     with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}), \
          patch("os.path.exists", MagicMock(return_value=True)):
         self.assertTrue(win_wusa.uninstall(path, restart=True))
     mock_retcode.assert_called_once_with(
         ['wusa.exe', '/uninstall', '/quiet', path, '/forcerestart'],
         ignore_retcode=True)
Beispiel #6
0
 def test_uninstall_kb(self):
     '''
     test uninstall function passing kb name
     '''
     mock_retcode = MagicMock(return_value=0)
     kb = 'KB123456'
     with patch.dict(win_wusa.__salt__, {'cmd.retcode': mock_retcode}), \
             patch("os.path.exists", MagicMock(return_value=False)):
         self.assertTrue(win_wusa.uninstall(kb))
     mock_retcode.assert_called_once_with(
         ['wusa.exe', '/uninstall', '/quiet', '/kb:{0}'.format(kb[2:]), '/norestart'],
         ignore_retcode=True)
Beispiel #7
0
 def test_uninstall_path_restart(self):
     """
     test uninstall function with full path and restart=True
     """
     mock_retcode = MagicMock(return_value=0)
     path = "C:\\KB123456.msu"
     with patch.dict(win_wusa.__salt__,
                     {"cmd.retcode": mock_retcode}), patch(
                         "os.path.exists", MagicMock(return_value=True)):
         self.assertTrue(win_wusa.uninstall(path, restart=True))
     mock_retcode.assert_called_once_with(
         ["wusa.exe", "/uninstall", "/quiet", path, "/forcerestart"],
         ignore_retcode=True,
     )
Beispiel #8
0
 def test_uninstall_kb(self):
     """
     test uninstall function passing kb name
     """
     mock_retcode = MagicMock(return_value=0)
     kb = "KB123456"
     with patch.dict(win_wusa.__salt__,
                     {"cmd.retcode": mock_retcode}), patch(
                         "os.path.exists", MagicMock(return_value=False)):
         self.assertTrue(win_wusa.uninstall(kb))
     mock_retcode.assert_called_once_with(
         [
             "wusa.exe",
             "/uninstall",
             "/quiet",
             "/kb:{}".format(kb[2:]),
             "/norestart",
         ],
         ignore_retcode=True,
     )