fix(tests): remove misleading env vars from langfuse None-guard tests

The env vars in the regression tests had no effect — the functions under
test operate only on the params dict and don't read from env vars.
Clean up the test setup to avoid misleading future maintainers.

Greptile feedback: P2
This commit is contained in:
Aman Sachan 2026-05-16 02:48:01 +00:00
parent e1d234e170
commit 036c3cd2c5
No known key found for this signature in database
GPG key ID: D50A9E263569B417

View file

@ -129,34 +129,26 @@ def test_langfuse_handler_accepts_secret_key_alias(monkeypatch):
assert captured["cached_logging_obj"] is logger
def test_dynamic_langfuse_credentials_are_passed_handles_none(monkeypatch):
def test_dynamic_langfuse_credentials_are_passed_handles_none():
"""Regression test: _dynamic_langfuse_credentials_are_passed must not crash when standard_callback_dynamic_params is None.
When Langfuse is configured via environment variables (no per-request dynamic params),
standard_callback_dynamic_params is None, not {}. The function must not raise
AttributeError: 'NoneType' object has no attribute 'get'.
"""
monkeypatch.setenv("LANGFUSE_PUBLIC_KEY", "pk-test")
monkeypatch.setenv("LANGFUSE_SECRET_KEY", "sk-test")
monkeypatch.setenv("LANGFUSE_HOST", "https://langfuse.example")
# Should return False (no dynamic params passed), not raise AttributeError
result = LangFuseHandler._dynamic_langfuse_credentials_are_passed(None)
assert result is False
def test_get_dynamic_langfuse_logging_config_handles_none(monkeypatch):
def test_get_dynamic_langfuse_logging_config_handles_none():
"""Regression test: get_dynamic_langfuse_logging_config must not crash when standard_callback_dynamic_params is None.
When Langfuse is configured via environment variables, standard_callback_dynamic_params is None.
The function should return a config with None values (relying on env var fallback downstream).
"""
monkeypatch.setenv("LANGFUSE_PUBLIC_KEY", "pk-test")
monkeypatch.setenv("LANGFUSE_SECRET_KEY", "sk-test")
monkeypatch.setenv("LANGFUSE_HOST", "https://langfuse.example")
# Should not raise AttributeError
config = LangFuseHandler.get_dynamic_langfuse_logging_config(None)
assert config["langfuse_public_key"] is None
assert config["langfuse_secret"] is None
assert config["langfuse_host"] is None
assert config.langfuse_public_key is None
assert config.langfuse_secret is None
assert config.langfuse_host is None