diff --git a/apps/api/tests/test_host_repair_agent.py b/apps/api/tests/test_host_repair_agent.py index 74548f2dc..7cba547ef 100644 --- a/apps/api/tests/test_host_repair_agent.py +++ b/apps/api/tests/test_host_repair_agent.py @@ -9,6 +9,24 @@ import pytest from unittest.mock import AsyncMock, patch +class _IsolatedRedisLock: + def __init__(self, *_args, **_kwargs): + self.acquired = False + + async def acquire(self) -> bool: + self.acquired = True + return True + + async def release(self) -> bool: + self.acquired = False + return True + + +@pytest.fixture(autouse=True) +def isolate_distributed_repair_lock(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr("src.core.redis_client.RedisLock", _IsolatedRedisLock) + + # ============================================================================= # 測試 HostRepairConfig 路由 # =============================================================================