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>
This commit is contained in:
yucheng 2026-09-23 19:39:12 +00:00
parent 59a2e81b3a
commit a1e9593f3e

View file

@ -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)