Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test: add regression tests for JID suffix classification and LID cache
Xubin Ren897d5a7e5843
diff --git a/tests/channels/test_whatsapp_channel.py b/tests/channels/test_whatsapp_channel.pyindex f285e4dbe..b61033677 100644--- a/tests/channels/test_whatsapp_channel.py+++ b/tests/channels/test_whatsapp_channel.py@@ -163,6 +163,60 @@ async def test_group_policy_mention_accepts_mentioned_group_message():assert kwargs["sender_id"] == "user"+async def test_sender_id_prefers_phone_jid_over_lid():+ """sender_id should resolve to phone number when @s.whatsapp.net JID is present."""+ ch = WhatsAppChannel({"enabled": True}, MagicMock())+ ch._handle_message = AsyncMock()++ await ch._handle_bridge_message(+ json.dumps({+ "type": "message",+ "id": "lid1",+ "sender": "[email protected]",+ "pn": "[email protected]",+ "content": "hi",+ "timestamp": 1,+ })+ )++ kwargs = ch._handle_message.await_args.kwargs+ assert kwargs["sender_id"] == "5551234"+++async def test_lid_to_phone_cache_resolves_lid_only_messages():+ """When only LID is present, a cached LID→phone mapping should be used."""+ ch = WhatsAppChannel({"enabled": True}, MagicMock())+ ch._handle_message = AsyncMock()++ # First message: both phone and LID → builds cache+ await ch._handle_bridge_message(+ json.dumps({+ "type": "message",+ "id": "c1",+ "sender": "[email protected]",+ "pn": "[email protected]",+ "content": "first",+ "timestamp": 1,+ })+ )+ # Second message: only LID, no phone+ await ch._handle_bridge_message(+ json.dumps({+ "type": "message",+ "id": "c2",+ "sender": "[email protected]",+ "pn": "",+ "content": "second",+ "timestamp": 2,+ })+ )++ second_kwargs = ch._handle_message.await_args_list[1].kwargs+ assert second_kwargs["sender_id"] == "5559999"++@pytest.mark.asyncioasync def test_voice_message_transcription_uses_media_path():"""Voice messages are transcribed when media path is available."""