2018-03-01 12:13:15 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2018-03-01 12:13:15 +01:00
|
|
|
class FlockHookTests(WebhookTestCase):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "test"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/flock?api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "flock"
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "This is the welcome message!"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"messages", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reply(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "It's interesting how high productivity will go..."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reply", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_note(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Shared a note"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"note", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reply_note(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "This is reply to Note."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reply_note", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reply_pinned(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "This is reply to pinned message."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reply_pinned", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reply_reminder(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "This is a reply to Reminder."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reply_reminder", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reply_todo(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "This is a reply to Todo notification."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reply_todo", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_pinned(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Rishabh rawat pinned an item to the conversation"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"pinned", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_reminder(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Rishabh rawat wanted me to remind All"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"reminder", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_todo(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Flock notifications"
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Rishabh rawat added a to-do in New List 1 list"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"todo", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|