2017-11-16 00:43:10 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2017-02-08 18:43:16 +01:00
|
|
|
class HomeAssistantHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "homeassistant"
|
2018-03-16 22:53:50 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/homeassistant?&api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "homeassistant"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_simplereq(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "homeassistant"
|
2017-02-19 06:51:08 +01:00
|
|
|
expected_message = "The sun will be shining today!"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"simplereq",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|
2017-02-19 06:51:08 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_req_with_title(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Weather forecast"
|
2017-02-19 06:51:08 +01:00
|
|
|
expected_message = "It will be 30 degrees Celsius out there today!"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"reqwithtitle",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|