From a1e9593f3e0d6c37975f1e76875b407e5bdc8a5c Mon Sep 17 00:00:00 2001 From: yucheng Date: Wed, 23 Sep 2026 19:39:12 +0000 Subject: [PATCH] test(langfuse): stub the logger in the health auth_check test instead of dialing a closed port Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../health_endpoints/test_health_endpoints.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py index 67008ea2ffb..fbb5aeabf2d 100644 --- a/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py +++ b/tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py @@ -4186,11 +4186,15 @@ async def test_health_services_endpoint_langfuse_missing_keys_errors(monkeypatch """v2 raised out of ``auth_check`` and the endpoint printed the server's answer; the v4 check returns the failure as a value, and the endpoint has to error with that reason rather than a generic credentials message that reads the same for an outage and a bad key.""" - for key in ("LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY", "LANGFUSE_BASE_URL", "LANGFUSE_MOCK"): - monkeypatch.delenv(key, raising=False) - monkeypatch.setenv("LANGFUSE_HOST", "http://127.0.0.1:9") - monkeypatch.setattr(litellm, "initialized_langfuse_clients", litellm.initialized_langfuse_clients) + import litellm.integrations.langfuse.langfuse as langfuse_module + from litellm.integrations.langfuse.langfuse_sdk import AuthCheckFailure + + logger_class = MagicMock() + logger_class.return_value.api_client.auth_check.return_value = AuthCheckFailure( + "connection refused by lf.internal.example" + ) + monkeypatch.setattr(langfuse_module, "LangFuseLogger", logger_class) with pytest.raises(ProxyException, match="auth_check failed") as raised: await health_services_endpoint(service="langfuse") - assert "127.0.0.1" in str(raised.value.message) or "refused" in str(raised.value.message).lower() + assert "connection refused by lf.internal.example" in str(raised.value.message)