補 PPT AiderHeal 去重鎖
All checks were successful
CD Pipeline / deploy (push) Successful in 1m5s

This commit is contained in:
OoO
2026-05-19 00:35:11 +08:00
parent 02682c81ed
commit e60707cdfb
5 changed files with 67 additions and 2 deletions

View File

@@ -565,6 +565,51 @@ def test_ppt_audit_trigger_aider_heal_accepts_issue_summary(client, monkeypatch)
assert captured['context']['issue_summary'] == 'S1: 圖表被切掉:右側圖例超出邊界'
def test_ppt_audit_trigger_aider_heal_dedupes_same_file(client, monkeypatch):
"""同一份 PPT 已在背景修復時,重複按鈕不應重開第二條 AiderHeal。"""
from routes import admin_observability_routes as mod
from services import aider_heal_executor as svc
calls = []
def fake_execute_code_fix(**kwargs):
calls.append(kwargs)
return {
'success': True,
'action': 'CODE_FIX',
'message': '不應在此測試執行',
'commit_sha': None,
'reverted': False,
}
class HoldingThread:
def __init__(self, target, **_kwargs):
self.target = target
def start(self):
return None
monkeypatch.setattr(svc, 'execute_code_fix', fake_execute_code_fix)
monkeypatch.setattr(mod.threading, 'Thread', HoldingThread)
mod._PPT_AIDER_HEAL_ACTIVE.clear()
payload = {
'pptx_filename': 'ocbot_daily_20260517.pptx',
'issue_summary': 'S1: 圖表被切掉:右側圖例超出邊界',
}
first = client.post('/observability/ppt_audit/trigger_aider_heal', json=payload)
second = client.post('/observability/ppt_audit/trigger_aider_heal', json=payload)
try:
assert first.status_code == 202
assert first.get_json()['status'] == 'queued'
assert second.status_code == 202
assert second.get_json()['status'] == 'already_running'
assert calls == []
finally:
mod._PPT_AIDER_HEAL_ACTIVE.clear()
# ──────────────────────────────────────────────────────────────────────────
# /observability/host_health
# ──────────────────────────────────────────────────────────────────────────