Ejemplo n.º 1
0
def test_test():
    """
    Test for Test if an entry is in the specified set.
    """
    assert ipset.test() == "Error: Set needs to be specified"

    assert ipset.test("s") == "Error: Entry needs to be specified"

    with patch.object(ipset, "_find_set_type", return_value=None):
        assert ipset.test("set", "entry") == "Error: Set set does not exist"

    with patch.object(ipset, "_find_set_type", return_value=True):
        mock = MagicMock(side_effect=[{"retcode": 1}, {"retcode": -1}])
        with patch.dict(ipset.__salt__, {"cmd.run_all": mock}):
            assert not ipset.test("set", "entry")
            assert ipset.test("set", "entry")
Ejemplo n.º 2
0
    def test_test(self):
        '''
        Test for Test if an entry is in the specified set.
        '''
        self.assertEqual(ipset.test(), 'Error: Set needs to be specified')

        self.assertEqual(ipset.test('s'), 'Error: Entry needs to be specified')

        with patch.object(ipset, '_find_set_type', return_value=None):
            self.assertEqual(ipset.test('set', 'entry'),
                             'Error: Set set does not exist')

        with patch.object(ipset, '_find_set_type', return_value=True):
            mock = MagicMock(side_effect=[{'retcode': 1}, {'retcode': -1}])
            with patch.dict(ipset.__salt__, {'cmd.run_all': mock}):
                self.assertFalse(ipset.test('set', 'entry'))
                self.assertTrue(ipset.test('set', 'entry'))
Ejemplo n.º 3
0
    def test_test(self):
        '''
        Test for Test if an entry is in the specified set.
        '''
        self.assertEqual(ipset.test(), 'Error: Set needs to be specified')

        self.assertEqual(ipset.test('s'),
                         'Error: Entry needs to be specified')

        with patch.object(ipset, '_find_set_type', return_value=None):
            self.assertEqual(ipset.test('set', 'entry'),
                             'Error: Set set does not exist')

        with patch.object(ipset, '_find_set_type', return_value=True):
            mock = MagicMock(side_effect=[{'retcode': 1}, {'retcode': -1}])
            with patch.dict(ipset.__salt__, {'cmd.run_all': mock}):
                self.assertFalse(ipset.test('set', 'entry'))
                self.assertTrue(ipset.test('set', 'entry'))