zulip/zerver/webhooks/flock/tests.py

90 lines
4.2 KiB
Python
Raw Normal View History

2018-03-01 12:13:15 +01:00
from zerver.lib.test_classes import WebhookTestCase
2018-03-01 12:13:15 +01:00
class FlockHookTests(WebhookTestCase):
STREAM_NAME = 'test'
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:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reply(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_note(self) -> None:
expected_topic = "Flock notifications"
expected_message = "Shared a note"
2018-03-01 12:13:15 +01:00
self.send_and_test_stream_message('note',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reply_note(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reply_pinned(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reply_reminder(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reply_todo(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_pinned(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_reminder(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def test_flock_todo(self) -> None:
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',
expected_topic,
2018-03-01 12:13:15 +01:00
expected_message,
content_type="application/json")
def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("flock", fixture_name, file_type="json")