mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
Update channel dispatch UX and harden sidecar startup behavior.
This aligns Weixin/WhatsApp with admin-managed model routing by adding channel/account-level specialist controls, improves OSS startup resilience by skipping missing sidecars gracefully, and refreshes runbook/readme guidance for the new default behavior and Weixin OpenAI-key silent handling. Made-with: Cursor
This commit is contained in:
parent
b1a0f94cd6
commit
5ab69e88d3
29 changed files with 1226 additions and 100 deletions
|
|
@ -121,6 +121,46 @@ class WeixinIlinkApiTests(unittest.TestCase):
|
|||
finally:
|
||||
weixin_ilink_api._process_inbound_payload_usecase = old_usecase # type: ignore[assignment]
|
||||
|
||||
def test_whatsapp_native_reply_returns_sync_replies(self) -> None:
|
||||
old_usecase = weixin_ilink_api._process_inbound_payload_usecase
|
||||
|
||||
def _fake_usecase(payload: dict[str, object]) -> dict[str, object]:
|
||||
text = str(payload.get("text") or "")
|
||||
self.assertEqual(str(payload.get("channel") or ""), "whatsapp")
|
||||
self.assertEqual(str(payload.get("user_id") or ""), "8613800138000@s.whatsapp.net")
|
||||
return {
|
||||
"ok": True,
|
||||
"replies": [
|
||||
{
|
||||
"chat_id": str(payload.get("chat_id") or ""),
|
||||
"text": f"wa:{text}",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
try:
|
||||
weixin_ilink_api._process_inbound_payload_usecase = _fake_usecase # type: ignore[assignment]
|
||||
r = self.client.post(
|
||||
"/whatsapp/native/reply",
|
||||
headers=self.headers,
|
||||
json={
|
||||
"account_id": "wa-bot-1",
|
||||
"ctx": {
|
||||
"From": "8613800138000@s.whatsapp.net",
|
||||
"To": "8613800138000@s.whatsapp.net",
|
||||
"Body": "hello whatsapp",
|
||||
},
|
||||
},
|
||||
)
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
data = r.json() or {}
|
||||
self.assertTrue(data.get("ok"), data)
|
||||
replies = data.get("replies") if isinstance(data.get("replies"), list) else []
|
||||
self.assertEqual(len(replies), 1, data)
|
||||
self.assertEqual(str((replies[0] or {}).get("text") or ""), "wa:hello whatsapp")
|
||||
finally:
|
||||
weixin_ilink_api._process_inbound_payload_usecase = old_usecase # type: ignore[assignment]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue