def test_checkIptables(self, subproc_popen_mock): hostInfo = HostInfo() p = MagicMock() subproc_popen_mock.return_value = p result = hostInfo.checkIptables() self.assertTrue(result == True) result = hostInfo.checkIptables() self.assertFalse(result == False)
def test_checkIptables(self, subproc_popen_mock): hostInfo = HostInfo() p = MagicMock() p.communicate.return_value = ['Table: filter'] subproc_popen_mock.return_value = p result = hostInfo.checkIptables() self.assertTrue(result) p.communicate.return_value = [''] result = hostInfo.checkIptables() self.assertFalse(result) p.communicate.return_value = ['iptables: Firewall is not running.'] result = hostInfo.checkIptables() self.assertFalse(result)