feat(agent-office): issue_* 텔레그램 콜백 디스패치
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,3 +73,48 @@ async def test_callback_reject_marks_rejected(monkeypatch):
|
||||
res = await agent.on_callback("issue_reject", {"slate_id": 8})
|
||||
assert res["ok"] is True
|
||||
dec.assert_awaited_once_with(8, "rejected")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_insta_issue_dispatch(monkeypatch):
|
||||
"""_handle_insta_issue: issue_approve_8 → on_callback('issue_approve', {slate_id:8})."""
|
||||
import sys
|
||||
# stub api_call so answerCallbackQuery doesn't hit real Telegram
|
||||
import app.telegram.webhook as wh
|
||||
monkeypatch.setattr(wh, "api_call", AsyncMock(return_value={"ok": True}))
|
||||
|
||||
agent = InstaAgent()
|
||||
on_cb = AsyncMock(return_value={"ok": True})
|
||||
monkeypatch.setattr(agent, "on_callback", on_cb)
|
||||
|
||||
from app.agents import AGENT_REGISTRY
|
||||
old = AGENT_REGISTRY.get("insta")
|
||||
AGENT_REGISTRY["insta"] = agent
|
||||
try:
|
||||
result = await wh._handle_insta_issue(
|
||||
{"id": "cq1", "data": "issue_approve_8"},
|
||||
"issue_approve_8",
|
||||
)
|
||||
finally:
|
||||
if old is None:
|
||||
AGENT_REGISTRY.pop("insta", None)
|
||||
else:
|
||||
AGENT_REGISTRY["insta"] = old
|
||||
|
||||
on_cb.assert_awaited_once_with("issue_approve", {"slate_id": 8})
|
||||
assert result["ok"] is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_handle_insta_issue_invalid_data(monkeypatch):
|
||||
"""_handle_insta_issue: 잘못된 callback_data → ok=False, error=invalid_callback_data."""
|
||||
import app.telegram.webhook as wh
|
||||
monkeypatch.setattr(wh, "api_call", AsyncMock(return_value={"ok": True}))
|
||||
monkeypatch.setattr("app.telegram.messaging.send_raw", AsyncMock())
|
||||
|
||||
result = await wh._handle_insta_issue(
|
||||
{"id": "cq2", "data": "issue_bad"},
|
||||
"issue_bad",
|
||||
)
|
||||
assert result["ok"] is False
|
||||
assert result["error"] == "invalid_callback_data"
|
||||
|
||||
Reference in New Issue
Block a user