def test_rename_set(): """ Test for Delete ipset set. """ assert ipset.rename_set() == "Error: Set needs to be specified" assert ipset.rename_set( "s") == "Error: New name for set needs to be specified" with patch.object(ipset, "_find_set_type", return_value=False): assert ipset.rename_set("s", "d") == "Error: Set does not exist" with patch.object(ipset, "_find_set_type", return_value=True): assert ipset.rename_set("s", "d") == "Error: New Set already exists" with patch.object(ipset, "_find_set_type", side_effect=[True, False]): with patch.object(ipset, "_ipset_cmd", return_value="A"): mock = MagicMock(return_value=True) with patch.dict(ipset.__salt__, {"cmd.run": mock}): assert ipset.rename_set("set", "new_set")
def test_rename_set(self): ''' Test for Delete ipset set. ''' self.assertEqual(ipset.rename_set(), 'Error: Set needs to be specified') self.assertEqual(ipset.rename_set('s'), 'Error: New name for set needs to be specified') with patch.object(ipset, '_find_set_type', return_value=False): self.assertEqual(ipset.rename_set('s', 'd'), 'Error: Set does not exist') with patch.object(ipset, '_find_set_type', return_value=True): self.assertEqual(ipset.rename_set('s', 'd'), 'Error: New Set already exists') with patch.object(ipset, '_find_set_type', side_effect=[True, False]): with patch.object(ipset, '_ipset_cmd', return_value='A'): mock = MagicMock(return_value=True) with patch.dict(ipset.__salt__, {'cmd.run': mock}): self.assertTrue(ipset.rename_set('set', 'new_set'))