# test_aider_event_processor | 2026-04-22 @ Asia/Taipei # 需真實 DB 的三個測試已移至 tests/integration/test_aider_event_processor_integration.py # 此檔案只保留無 DB 依賴的純單元測試,符合 CI 架構(tests/ 層不連 DB)。 """Unit tests for AiderEventProcessor — 無 DB 依賴。""" import pytest from unittest.mock import AsyncMock, MagicMock @pytest.mark.asyncio async def test_process_one_malformed_payload_acks_and_skips(monkeypatch): """malformed JSON 應 ACK 避免卡 pending,且不觸碰 DB。""" from src.workers.aider_event_processor import AiderEventProcessor fake_r = MagicMock() fake_r.xack = AsyncMock() monkeypatch.setattr("src.workers.aider_event_processor.get_worker_redis", lambda: fake_r) proc = AiderEventProcessor() data = {b"payload": b"this is not json"} await proc._process_one("stream", "1-0", data) fake_r.xack.assert_called_once()