def test_remove(self): ''' Tests to remove the specified kernel module ''' mod = 'cheese' err_msg = 'Cannot find module: it has been eaten' mock_persist = MagicMock(return_value=set([mod])) mock_lsmod = MagicMock(return_value=[{'size': 100, 'module': None, 'depcount': 10, 'deps': None}]) mock_run_all_0 = MagicMock(return_value={'retcode': 0}) mock_run_all_1 = MagicMock(return_value={'retcode': 1, 'stderr': err_msg}) with patch('salt.modules.kmod._remove_persistent_module', mock_persist): with patch('salt.modules.kmod.lsmod', mock_lsmod): with patch.dict(kmod.__salt__, {'cmd.run_all': mock_run_all_0}): self.assertEqual([mod], kmod.remove(mod, True)) self.assertEqual([], kmod.remove(mod)) with patch.dict(kmod.__salt__, {'cmd.run_all': mock_run_all_1}): self.assertEqual('Error removing module {0}: {1}'.format(mod, err_msg), kmod.remove(mod, True))
def test_remove(self): """ Tests to remove the specified kernel module """ mod = "cheese" err_msg = "Cannot find module: it has been eaten" mock_persist = MagicMock(return_value=set([mod])) mock_lsmod = MagicMock( return_value=[{"size": 100, "module": None, "depcount": 10, "deps": None}] ) mock_run_all_0 = MagicMock(return_value={"retcode": 0}) mock_run_all_1 = MagicMock(return_value={"retcode": 1, "stderr": err_msg}) with patch("salt.modules.kmod._remove_persistent_module", mock_persist): with patch("salt.modules.kmod.lsmod", mock_lsmod): with patch.dict(kmod.__salt__, {"cmd.run_all": mock_run_all_0}): self.assertEqual([mod], kmod.remove(mod, True)) self.assertEqual([], kmod.remove(mod)) with patch.dict(kmod.__salt__, {"cmd.run_all": mock_run_all_1}): self.assertEqual( "Error removing module {0}: {1}".format(mod, err_msg), kmod.remove(mod, True), )
def test_remove(self): ''' Tests to remove the specified kernel module ''' mock_ret = [{'size': 100, 'module': None, 'depcount': 10, 'deps': None}] with patch('salt.modules.kmod.lsmod', MagicMock(return_value=mock_ret)): mock = MagicMock(return_value=0) with patch.dict(kmod.__salt__, {'cmd.run_all': mock}): self.assertEqual(['lp'], kmod.remove('lp', True)) self.assertEqual([], kmod.remove('lp'))
def test_remove(self): """ Tests to remove the specified kernel module """ mock_ret = [{"size": 100, "module": None, "depcount": 10, "deps": None}] with patch("salt.modules.kmod.lsmod", MagicMock(return_value=mock_ret)): mock = MagicMock(return_value=0) with patch.dict(kmod.__salt__, {"cmd.run_all": mock}): self.assertEqual(["lp"], kmod.remove("lp", True)) self.assertEqual([], kmod.remove("lp"))