Add Slack thread/reply support (#93384)

This commit is contained in:
Fletcher
2023-09-21 11:06:55 +02:00
committed by GitHub
parent e4742c04f2
commit 11c4c37cf9
5 changed files with 46 additions and 6 deletions
+16
View File
@@ -6,6 +6,7 @@ from unittest.mock import AsyncMock, Mock
from homeassistant.components import notify
from homeassistant.components.slack import DOMAIN
from homeassistant.components.slack.notify import (
ATTR_THREAD_TS,
CONF_DEFAULT_CHANNEL,
SlackNotificationService,
)
@@ -93,3 +94,18 @@ async def test_message_icon_url_overrides_default() -> None:
mock_fn.assert_called_once()
_, kwargs = mock_fn.call_args
assert kwargs["icon_url"] == expected_icon
async def test_message_as_reply() -> None:
"""Tests that a message pointer will be passed to Slack if specified."""
mock_client = Mock()
mock_client.chat_postMessage = AsyncMock()
service = SlackNotificationService(None, mock_client, CONF_DATA)
expected_ts = "1624146685.064129"
await service.async_send_message("test", data={ATTR_THREAD_TS: expected_ts})
mock_fn = mock_client.chat_postMessage
mock_fn.assert_called_once()
_, kwargs = mock_fn.call_args
assert kwargs["thread_ts"] == expected_ts