From 579078f46896eb39f0db22aa201b11c0152489b0 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Fri, 6 Mar 2026 16:26:58 -0800 Subject: [PATCH] fix test: configure async_delete_cache as AsyncMock and assert cleanup called --- tests/test_litellm/proxy/management_endpoints/test_ui_sso.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py b/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py index 13a2df26d47..5b05e16cf72 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py +++ b/tests/test_litellm/proxy/management_endpoints/test_ui_sso.py @@ -3801,6 +3801,7 @@ class TestPKCEFunctionality: # Cache returns an integer — unexpected format mock_cache = MagicMock() mock_cache.async_get_cache = AsyncMock(return_value=12345) + mock_cache.async_delete_cache = AsyncMock() mock_request = MagicMock(spec=Request) mock_request.query_params = {"state": "bad_format_state"} @@ -3917,6 +3918,7 @@ class TestPKCEFunctionality: # Cache returns an integer — unexpected format mock_cache = MagicMock() mock_cache.async_get_cache = AsyncMock(return_value=12345) + mock_cache.async_delete_cache = AsyncMock() mock_request = MagicMock(spec=Request) mock_request.query_params = {"state": "bad_format_non_strict"} @@ -3948,6 +3950,8 @@ class TestPKCEFunctionality: for r in caplog.records if r.levelno >= logging.WARNING ), f"Expected a format/cache warning. Records: {[r.message for r in caplog.records]}" + # Verify cleanup was attempted for the corrupt/stale cache entry + mock_cache.async_delete_cache.assert_called_once() @pytest.mark.asyncio async def test_pkce_legacy_string_cache_format_backward_compat(self):