2017-02-08 18:43:16 +01:00
|
|
|
from typing import Text
|
|
|
|
|
2017-11-16 00:43:10 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2017-02-08 18:43:16 +01:00
|
|
|
class HomeAssistantHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'homeassistant'
|
|
|
|
URL_TEMPLATE = "/api/v1/external/homeassistant?&api_key={api_key}"
|
|
|
|
FIXTURE_DIR_NAME = 'homeassistant'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_simplereq(self) -> None:
|
2017-02-19 06:51:08 +01:00
|
|
|
expected_subject = "homeassistant"
|
|
|
|
expected_message = "The sun will be shining today!"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('simplereq', expected_subject, 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:
|
2017-02-19 06:51:08 +01:00
|
|
|
expected_subject = "Weather forecast"
|
|
|
|
expected_message = "It will be 30 degrees Celsius out there today!"
|
2017-02-08 18:43:16 +01:00
|
|
|
|
|
|
|
self.send_and_test_stream_message('reqwithtitle', expected_subject, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def get_body(self, fixture_name: Text) -> Text:
|
2017-02-08 18:43:16 +01:00
|
|
|
return self.fixture_data("homeassistant", fixture_name, file_type="json")
|