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):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "homeassistant"
|
2018-03-16 22:53:50 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/homeassistant?&api_key={api_key}&stream={stream}"
|
2021-02-12 08:20:45 +01:00
|
|
|
FIXTURE_DIR_NAME = "homeassistant"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_simplereq(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "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",
|
|
|
|
expected_topic,
|
|
|
|
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:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "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",
|
|
|
|
expected_topic,
|
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|