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):
|
|
|
|
STREAM_NAME = 'test'
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/flock?api_key={api_key}&stream={stream}"
|
2018-03-01 12:13:15 +01:00
|
|
|
|
|
|
|
def test_flock_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "This is the welcome message!"
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('messages',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reply(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "It's interesting how high productivity will go..."
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reply',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_note(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "Shared a note"
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('note',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reply_note(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "This is reply to Note."
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reply_note',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reply_pinned(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "This is reply to pinned message."
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reply_pinned',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reply_reminder(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "This is a reply to Reminder."
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reply_reminder',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reply_todo(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "This is a reply to Todo notification."
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reply_todo',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_pinned(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "Rishabh rawat pinned an item to the conversation"
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('pinned',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_reminder(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "Rishabh rawat wanted me to remind All"
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('reminder',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
|
|
|
def test_flock_todo(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Flock notifications"
|
|
|
|
expected_message = "Rishabh rawat added a to-do in New List 1 list"
|
2018-03-01 12:13:15 +01:00
|
|
|
self.send_and_test_stream_message('todo',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2018-03-01 12:13:15 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/json")
|
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> str:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data("flock", fixture_name, file_type="json")
|