test(rate-limits): add direct litellm_metadata lookup coverage

The new _stash_value_in_internal_metadata helper routes stash writes to the
proxy-internal metadata bucket, which can be litellm_metadata on Responses
routes. The lookup logic was updated to read from both channels, but the test
only verified the legacy metadata path.

Add explicit assertion testing lookup when values live in
litellm_params["litellm_metadata"] to close the coverage gap Greptile flagged.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Yucheng Zhu 2026-07-30 10:21:34 -07:00
parent 68de15b01d
commit 29ef0504d7

View file

@ -3247,6 +3247,13 @@ async def test_pre_call_hook_does_not_touch_provider_metadata_on_litellm_metadat
key=key,
) == litellm_metadata.get(key)
for key in _LITELLM_STASH_KEYS:
assert handler._lookup_stashed_value(
kwargs={"litellm_params": {"litellm_metadata": litellm_metadata}},
standard_logging_metadata=None,
key=key,
) == litellm_metadata.get(key)
@pytest.mark.asyncio
async def test_pre_call_hook_rejects_caller_supplied_stash_values():