def test_reboot(self): ''' Test to reboot the system ''' mock = MagicMock(return_value='salt') with patch.dict(win_system.__salt__, {'cmd.run': mock}): self.assertEqual(win_system.reboot(), 'salt')
def test_reboot(self): ''' Test to reboot the system ''' with patch('salt.modules.win_system.shutdown', MagicMock(return_value=True)) as shutdown: self.assertEqual(win_system.reboot(), True)
def test_reboot(self): """ Test to reboot the system """ with patch("salt.modules.win_system.shutdown", MagicMock(return_value=True)): self.assertEqual(win_system.reboot(), True)
def test_reboot_with_timeout_in_seconds(self): ''' Test to reboot the system with a timeout ''' mock = MagicMock(return_value='salt') with patch.dict(win_system.__salt__, {'cmd.run': mock}): self.assertEqual(win_system.reboot(5, in_seconds=True), 'salt') mock.assert_called_once_with(['shutdown', '/r', '/t', '5'], python_shell=False)
def test_reboot(self): ''' Test to reboot the system ''' mock = MagicMock(return_value='salt') with patch.dict(win_system.__salt__, {'cmd.run': mock}): self.assertEqual(win_system.reboot(), 'salt') mock.assert_called_once_with(['shutdown', '/r', '/t', '300'], python_shell=False)
def test_reboot_with_timeout_in_seconds(self): ''' Test to reboot the system with a timeout ''' with patch('salt.modules.win_system.shutdown', MagicMock(return_value=True)) as shutdown: self.assertEqual(win_system.reboot(5, in_seconds=True), True) shutdown.assert_called_with(timeout=5, in_seconds=True, reboot=True, only_on_pending_reboot=False)
def test_reboot_with_wait(self): """ Test to reboot the system with a timeout and wait for it to finish """ with patch( "salt.modules.win_system.shutdown", MagicMock(return_value=True) ), patch("salt.modules.win_system.time.sleep", MagicMock()) as time: self.assertEqual(win_system.reboot(wait_for_reboot=True), True) time.assert_called_with(330)
def test_reboot_with_wait(self): ''' Test to reboot the system with a timeout and wait for it to finish ''' mock = MagicMock(return_value='salt') sleep_mock = MagicMock(return_value='salt') with patch.dict(win_system.__salt__, {'cmd.run': mock}): with patch('time.sleep', sleep_mock): self.assertEqual(win_system.reboot(wait_for_reboot=True), 'salt') mock.assert_called_once_with(['shutdown', '/r', '/t', '300'], python_shell=False) sleep_mock.assert_called_once_with(330)