mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-22 05:22:09 +00:00
fix(dingtalk): clarify webhook media behavior
This commit is contained in:
parent
a33c63b9f8
commit
c705c7ac9b
2 changed files with 104 additions and 0 deletions
|
|
@ -223,6 +223,51 @@ class TestSend:
|
|||
assert result.success is False
|
||||
assert "400" in result.error
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_image_renders_markdown_image(self):
|
||||
from gateway.platforms.dingtalk import DingTalkAdapter
|
||||
adapter = DingTalkAdapter(PlatformConfig(enabled=True))
|
||||
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.text = "OK"
|
||||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.post = AsyncMock(return_value=mock_response)
|
||||
adapter._http_client = mock_client
|
||||
|
||||
result = await adapter.send_image(
|
||||
"chat-123",
|
||||
"https://example.com/demo.png",
|
||||
caption="Screenshot",
|
||||
metadata={"session_webhook": "https://dingtalk.example/webhook"},
|
||||
)
|
||||
|
||||
assert result.success is True
|
||||
payload = mock_client.post.call_args.kwargs["json"]
|
||||
assert payload["msgtype"] == "markdown"
|
||||
assert payload["markdown"]["text"] == "Screenshot\n\n"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_image_file_returns_explicit_unsupported_error(self):
|
||||
from gateway.platforms.dingtalk import DingTalkAdapter
|
||||
adapter = DingTalkAdapter(PlatformConfig(enabled=True))
|
||||
|
||||
result = await adapter.send_image_file("chat-123", "/tmp/demo.png")
|
||||
|
||||
assert result.success is False
|
||||
assert "do not support local image uploads" in result.error
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_document_returns_explicit_unsupported_error(self):
|
||||
from gateway.platforms.dingtalk import DingTalkAdapter
|
||||
adapter = DingTalkAdapter(PlatformConfig(enabled=True))
|
||||
|
||||
result = await adapter.send_document("chat-123", "/tmp/demo.pdf")
|
||||
|
||||
assert result.success is False
|
||||
assert "do not support local file attachments" in result.error
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Connect / disconnect
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue