def test_check_chain(self): ''' Test if it check for the existence of a chain in the table ''' self.assertEqual(nftables.check_chain(), { 'result': False, 'comment': 'Chain needs to be specified' }) mock = MagicMock(return_value='') ret = { 'comment': 'Chain input in table filter in family ipv4 does not exist', 'result': False } with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertEqual(nftables.check_chain(chain='input'), ret) mock = MagicMock(return_value='chain input {{') ret = { 'comment': 'Chain input in table filter in family ipv4 exists', 'result': True } with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertEqual(nftables.check_chain(chain='input'), ret)
def test_check_chain(self): """ Test if it check for the existence of a chain in the table """ self.assertEqual( nftables.check_chain(), { "result": False, "comment": "Chain needs to be specified" }, ) mock = MagicMock(return_value="") ret = { "comment": "Chain input in table filter in family ipv4 does not exist", "result": False, } with patch.dict(nftables.__salt__, {"cmd.run": mock}): self.assertEqual(nftables.check_chain(chain="input"), ret) mock = MagicMock(return_value="chain input {{") ret = { "comment": "Chain input in table filter in family ipv4 exists", "result": True, } with patch.dict(nftables.__salt__, {"cmd.run": mock}): self.assertEqual(nftables.check_chain(chain="input"), ret)
def test_check_chain(self): ''' Test if it check for the existence of a chain in the table ''' self.assertEqual(nftables.check_chain(), 'Error: Chain needs to be specified') mock = MagicMock(return_value='') with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertFalse(nftables.check_chain(chain='input')) mock = MagicMock(return_value='chain input {{') with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertTrue(nftables.check_chain(chain='input'))
def test_check_chain(self): ''' Test if it check for the existence of a chain in the table ''' self.assertEqual(nftables.check_chain(), 'Error: Chain needs to be specified') mock = MagicMock(return_value='') with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertFalse(nftables.check_chain(chain='input')) mock = MagicMock(return_value='chain input {{') with patch.dict(nftables.__salt__, {'cmd.run': mock}): self.assertTrue(nftables.check_chain(chain='input'))