test(faros): cover callback retrieval path, empty batch, and no-event-loop init

https://claude.ai/code/session_01S79266vJDYzh7ay3nQ9ENW
This commit is contained in:
mateo-berri 2026-06-10 19:07:56 +00:00
parent 1f7d1f912c
commit a547735dd4
No known key found for this signature in database

View file

@ -38,13 +38,17 @@ def make_kwargs(
}
@pytest.mark.asyncio
async def test_init_requires_api_key(monkeypatch):
def test_init_requires_api_key(monkeypatch):
monkeypatch.delenv("FAROS_API_KEY", raising=False)
with pytest.raises(ValueError, match="FAROS_API_KEY"):
FarosLogger()
def test_init_without_running_event_loop():
logger = make_logger()
assert logger.flush_lock is not None
@pytest.mark.asyncio
async def test_user_uid_resolution_priority():
logger = make_logger()
@ -189,15 +193,26 @@ def test_faros_is_a_registered_callback():
@pytest.mark.asyncio
async def test_init_custom_logger_compatible_class_returns_singleton(monkeypatch):
from litellm.litellm_core_utils.litellm_logging import (
_init_custom_logger_compatible_class,
_in_memory_loggers,
_init_custom_logger_compatible_class,
get_custom_logger_compatible_class,
)
monkeypatch.setenv("FAROS_API_KEY", "test-key")
assert get_custom_logger_compatible_class("faros") is None
created = _init_custom_logger_compatible_class("faros", None, None)
try:
assert isinstance(created, FarosLogger)
again = _init_custom_logger_compatible_class("faros", None, None)
assert again is created
assert get_custom_logger_compatible_class("faros") is created
finally:
_in_memory_loggers.remove(created)
@pytest.mark.asyncio
async def test_send_batch_with_empty_queue_does_not_post():
mock_post = AsyncMock()
logger = make_logger(mock_post=mock_post)
await logger.async_send_batch()
mock_post.assert_not_awaited()