From acfa0f45317eacd1bab2cc247d1f102fe1f191fc Mon Sep 17 00:00:00 2001 From: rzeta-10 Date: Mon, 23 Mar 2026 22:48:18 +0530 Subject: [PATCH] address greptile issues - Add async health check tests for AktoLogger --- .../test_akto_logger.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/logging_callback_tests/test_akto_logger.py b/tests/logging_callback_tests/test_akto_logger.py index 67a3aed5613..47212b9b6ab 100644 --- a/tests/logging_callback_tests/test_akto_logger.py +++ b/tests/logging_callback_tests/test_akto_logger.py @@ -335,3 +335,29 @@ async def test_async_log_failure_swallows_errors(logger): start_time=None, end_time=None, ) + + +# ── Health check ── + + +@pytest.mark.asyncio +async def test_async_health_check_healthy(logger): + logger.async_http_handler.get = AsyncMock(return_value=MagicMock(status_code=200)) + result = await logger.async_health_check() + assert result["status"] == "healthy" + assert result["error_message"] is None + + +@pytest.mark.asyncio +async def test_async_health_check_unhealthy(logger): + logger.async_http_handler.get = AsyncMock(return_value=MagicMock(status_code=503)) + result = await logger.async_health_check() + assert result["status"] == "unhealthy" + assert "503" in result["error_message"] + + +@pytest.mark.asyncio +async def test_async_health_check_exception(logger): + logger.async_http_handler.get = AsyncMock(side_effect=httpx.ConnectError("refused")) + result = await logger.async_health_check() + assert result["status"] == "unhealthy"