From 6789987a30162993e5a007797d9e934dbc20749f Mon Sep 17 00:00:00 2001 From: ogt Date: Fri, 10 Jul 2026 00:42:41 +0800 Subject: [PATCH] test(host-repair): isolate redis repair lock --- apps/api/tests/test_host_repair_agent.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 路由 # =============================================================================