def test_show_states(): """ Tests show states command. """ ret = {} ret["stdout"] = "all udp 192.168.1.1:3478\n" ret["retcode"] = 0 expected = ["all udp 192.168.1.1:3478", ""] mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}): assert pf.show("states")["comment"] == expected
def test_show_rules(): """ Tests show rules command. """ ret = {} ret["stdout"] = "block return\npass" ret["retcode"] = 0 expected = ["block return", "pass"] mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}): assert pf.show("rules")["comment"] == expected
def test_show(self): ''' Tests a regular show command. ''' ret = {} ret['stdout'] = 'block return\npass' ret['retcode'] = 0 expected = ['block return', 'pass'] mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {'cmd.run_all': mock_cmd}): self.assertListEqual(pf.show('rules')['comment'], expected)
def test_show(self): """ Tests a regular show command. """ ret = {} ret["stdout"] = "block return\npass" ret["retcode"] = 0 expected = ["block return", "pass"] mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}): self.assertListEqual(pf.show("rules")["comment"], expected)
def test_show_tables(): """ Tests show tables command. """ ret = {} ret["stdout"] = "bad_hosts" ret["retcode"] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}): res = pf.show("tables") mock_cmd.assert_called_once_with("pfctl -s Tables", output_loglevel="trace", python_shell=False) assert not res["changes"]
def test_show_capital(self): ''' Tests a show command starting with a capital letter. ''' ret = {} ret['stdout'] = 'bad_hosts' ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {'cmd.run_all': mock_cmd}): res = pf.show('tables') mock_cmd.assert_called_once_with('pfctl -s Tables', output_loglevel='trace', python_shell=False) self.assertFalse(res['changes'])
def test_show_capital(self): """ Tests a show command starting with a capital letter. """ ret = {} ret["stdout"] = "bad_hosts" ret["retcode"] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(pf.__salt__, {"cmd.run_all": mock_cmd}): res = pf.show("tables") mock_cmd.assert_called_once_with("pfctl -s Tables", output_loglevel="trace", python_shell=False) self.assertFalse(res["changes"])