Пример #1
0
 def test_loglevel(self):
     '''
     Tests setting a loglevel.
     '''
     ret = {}
     ret['retcode'] = 0
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(pf.__salt__, {'cmd.run_all': mock_cmd}):
         res = pf.loglevel('crit')
         mock_cmd.assert_called_once_with('pfctl -x crit',
                                          output_loglevel='trace',
                                          python_shell=False)
         self.assertTrue(res['changes'])
Пример #2
0
 def test_loglevel(self):
     """
     Tests setting a loglevel.
     """
     ret = {}
     ret["retcode"] = 0
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}):
         res = pf.loglevel("crit")
         mock_cmd.assert_called_once_with(
             "pfctl -x crit", output_loglevel="trace", python_shell=False
         )
         self.assertTrue(res["changes"])
Пример #3
0
def test_loglevel_openbsd():
    """
    Tests setting a loglevel.
    """
    ret = {}
    ret["retcode"] = 0
    mock_cmd = MagicMock(return_value=ret)
    with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
            pf.__grains__, {"os": "OpenBSD"}):
        res = pf.loglevel("crit")
        mock_cmd.assert_called_once_with("pfctl -x crit",
                                         output_loglevel="trace",
                                         python_shell=False)
        assert res["changes"]
Пример #4
0
 def test_loglevel(self):
     '''
     Tests setting a loglevel.
     '''
     ret = {}
     ret['retcode'] = 0
     # FreeBSD and OpenBSD have different log levels available.
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(pf.__salt__, {'cmd.run_all': mock_cmd}), \
             patch.dict(pf.__grains__, {'os': 'FreeBSD'}):
         res = pf.loglevel('urgent')
         mock_cmd.assert_called_once_with('pfctl -x urgent',
                                          output_loglevel='trace',
                                          python_shell=False)
         self.assertTrue(res['changes'])
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(pf.__salt__, {'cmd.run_all': mock_cmd}), \
             patch.dict(pf.__grains__, {'os': 'OpenBSD'}):
         res = pf.loglevel('crit')
         mock_cmd.assert_called_once_with('pfctl -x crit',
                                          output_loglevel='trace',
                                          python_shell=False)
         self.assertTrue(res['changes'])