diff --git a/tests/unit/mcp/test_manager_byok.py b/tests/unit/mcp/test_manager_byok.py index 6997ccb..7b24294 100644 --- a/tests/unit/mcp/test_manager_byok.py +++ b/tests/unit/mcp/test_manager_byok.py @@ -1,6 +1,7 @@ """McpManager BYOK runtime — per-user clients, caching, fallback, LRU.""" import asyncio +import time from unittest.mock import MagicMock import pytest @@ -233,9 +234,11 @@ manager._evict_idle_user_clients() assert ("http-server", "u1") in manager._user_clients - # Backdate last-used past the idle threshold, then reap again. + # Backdate last-used past the idle threshold, then reap again. Backdating + # to 0.0 assumed a host that has been up longer than the threshold. client, key, _ = manager._user_clients[("http-server", "u1")] - manager._user_clients[("http-server", "u1")] = (client, key, 0.0) + stale = time.monotonic() - manager_mod._USER_CLIENT_IDLE_SEC - 1 + manager._user_clients[("http-server", "u1")] = (client, key, stale) manager._evict_idle_user_clients() assert ("http-server", "u1") not in manager._user_clients