コード例 #1
0
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"
コード例 #2
0
ファイル: test_ipset.py プロジェクト: vindir/salt
    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')
コード例 #3
0
ファイル: ipset_test.py プロジェクト: DaveQB/salt
    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')