mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
This is preparatory work towards adding a Topic model. We plan to use the local variable name as 'topic' for the Topic model objects. Currently, we use *topic as the local variable name for topic names. We rename local variables of the form *topic to *topic_name so that we don't need to think about type collisions in individual code paths where we might want to talk about both Topic objects and strings for the topic name.
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class ZapierHookTests(WebhookTestCase):
|
|
STREAM_NAME = "zapier"
|
|
URL_TEMPLATE = "/api/v1/external/zapier?stream={stream}&api_key={api_key}"
|
|
WEBHOOK_DIR_NAME = "zapier"
|
|
|
|
def test_zapier_when_subject_and_body_are_correct(self) -> None:
|
|
expected_topic_name = "New email from zulip@zulip.com"
|
|
expected_message = "Your email content is: \nMy Email content."
|
|
self.check_webhook("correct_subject_and_body", expected_topic_name, expected_message)
|
|
|
|
def test_zapier_when_topic_and_body_are_correct(self) -> None:
|
|
expected_topic_name = "New email from zulip@zulip.com"
|
|
expected_message = "Your email content is: \nMy Email content."
|
|
self.check_webhook("correct_topic_and_body", expected_topic_name, expected_message)
|
|
|
|
def test_zapier_weather_update(self) -> None:
|
|
expected_topic_name = "Here is your weather update for the day:"
|
|
expected_message = (
|
|
"Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12"
|
|
)
|
|
self.check_webhook("weather_update", expected_topic_name, expected_message)
|
|
|
|
|
|
class ZapierZulipAppTests(WebhookTestCase):
|
|
STREAM_NAME = "zapier"
|
|
URL_TEMPLATE = "/api/v1/external/zapier?api_key={api_key}&stream={stream}"
|
|
WEBHOOK_DIR_NAME = "zapier"
|
|
|
|
def test_auth(self) -> None:
|
|
payload = self.get_body("zapier_zulip_app_auth")
|
|
result = self.client_post(self.url, payload, content_type="application/json")
|
|
json_result = self.assert_json_success(result)
|
|
self.assertEqual(json_result["full_name"], "Zulip Webhook Bot")
|
|
self.assertEqual(json_result["email"], "webhook-bot@zulip.com")
|
|
self.assertIn("id", json_result)
|