test_events: Add reaction tests.

This commit is contained in:
Tim Abbott 2017-03-22 20:04:19 -07:00
parent 0963f2d518
commit 60326ca94c
1 changed files with 50 additions and 0 deletions

View File

@ -20,6 +20,8 @@ from zerver.lib.actions import (
check_add_realm_emoji,
check_send_typing_notification,
do_add_realm_filter,
do_add_reaction,
do_remove_reaction,
do_change_avatar_fields,
do_change_default_all_public_streams,
do_change_default_events_register_stream,
@ -421,6 +423,54 @@ class EventsRegisterTest(ZulipTestCase):
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_send_reaction(self):
# type: () -> None
schema_checker = check_dict([
('type', equals('reaction')),
('op', equals('add')),
('message_id', check_int),
('emoji_name', check_string),
('user', check_dict([
('email', check_string),
('full_name', check_string),
('user_id', check_int)
])),
])
message_id = self.send_message("hamlet@zulip.com", "Verona", Recipient.STREAM, "hello")
message = Message.objects.get(id=message_id)
events = self.do_test(
lambda: do_add_reaction(
self.user_profile, message, "tada"),
state_change_expected=False,
)
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_remove_reaction(self):
# type: () -> None
schema_checker = check_dict([
('type', equals('reaction')),
('op', equals('remove')),
('message_id', check_int),
('emoji_name', check_string),
('user', check_dict([
('email', check_string),
('full_name', check_string),
('user_id', check_int)
])),
])
message_id = self.send_message("hamlet@zulip.com", "Verona", Recipient.STREAM, "hello")
message = Message.objects.get(id=message_id)
events = self.do_test(
lambda: do_remove_reaction(
self.user_profile, message, "tada"),
state_change_expected=False,
)
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_typing_events(self):
# type: () -> None
schema_checker = check_dict([