From f6e526c5bedd4b28d3aff387f364a17a7902a10b Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Tue, 14 Apr 2026 20:46:21 +0530 Subject: [PATCH] Fix bulk update tests --- .../test_key_management_endpoints.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py index a16bc078cf3..479defbff5c 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py @@ -5385,9 +5385,15 @@ async def test_bulk_update_keys_success(monkeypatch): ) as mock_hash: mock_hash.side_effect = ["hashed-key-1", "hashed-key-2"] + def _hash_for_bulk_success(token: str) -> str: + return { + "test-key-1": "hashed-key-1", + "test-key-2": "hashed-key-2", + }[token] + with patch( "litellm.proxy.management_endpoints.key_management_endpoints._hash_token_if_needed", - side_effect=["hashed-key-1", "hashed-key-2"], + side_effect=_hash_for_bulk_success, ): with patch( "litellm.proxy.management_endpoints.key_management_endpoints.KeyManagementEventHooks.async_key_updated_hook" @@ -5511,9 +5517,15 @@ async def test_bulk_update_keys_partial_failures(monkeypatch): ) as mock_hash: mock_hash.return_value = "hashed-key-1" + def _hash_for_bulk_partial(token: str) -> str: + return { + "test-key-1": "hashed-key-1", + "non-existent-key": "hashed-non-existent-key", + }[token] + with patch( "litellm.proxy.management_endpoints.key_management_endpoints._hash_token_if_needed", - side_effect=["hashed-key-1", "hashed-non-existent-key"], + side_effect=_hash_for_bulk_partial, ): with patch( "litellm.proxy.management_endpoints.key_management_endpoints.KeyManagementEventHooks.async_key_updated_hook"