def test_delete(): """ Test for Delete an entry from the specified set. """ assert ipset.delete() == "Error: Set needs to be specified" assert ipset.delete("s") == "Error: Entry needs to be specified" with patch.object(ipset, "_find_set_type", return_value=None): assert ipset.delete("set", "entry") == "Error: Set set does not exist" with patch.object(ipset, "_find_set_type", return_value=True): with patch.object(ipset, "_ipset_cmd", return_value="A"): mock = MagicMock(side_effect=["", "A"]) with patch.dict(ipset.__salt__, {"cmd.run": mock}): assert ipset.delete("set", "entry") == "Success" assert ipset.delete("set", "entry") == "Error: A"
def test_delete(self): ''' Test for Delete an entry from the specified set. ''' self.assertEqual(ipset.delete(), 'Error: Set needs to be specified') self.assertEqual(ipset.delete('s'), 'Error: Entry needs to be specified') with patch.object(ipset, '_find_set_type', return_value=None): self.assertEqual(ipset.delete('set', 'entry'), 'Error: Set set does not exist') with patch.object(ipset, '_find_set_type', return_value=True): with patch.object(ipset, '_ipset_cmd', return_value='A'): mock = MagicMock(side_effect=['', 'A']) with patch.dict(ipset.__salt__, {'cmd.run': mock}): self.assertEqual(ipset.delete('set', 'entry'), 'Success') self.assertEqual(ipset.delete('set', 'entry'), 'Error: A')