tests: Add coverage for message truncation logic.

This commit is contained in:
Steve Howell 2018-08-11 13:25:16 +00:00 committed by Tim Abbott
parent d0e377428a
commit 101446ec52
1 changed files with 16 additions and 0 deletions

View File

@ -18,6 +18,7 @@ from zerver.lib.actions import (
do_send_messages,
get_active_presence_idle_user_ids,
get_user_info_for_message_updates,
internal_prep_private_message,
internal_send_private_message,
check_message,
check_send_stream_message,
@ -359,6 +360,21 @@ class TestCrossRealmPMs(ZulipTestCase):
self.send_huddle_message(user1_email, [user2_email, user3_email],
sender_realm="1.example.com")
class InternalPrepTest(ZulipTestCase):
def test_error_handling(self) -> None:
realm = get_realm('zulip')
sender = self.example_user('cordelia')
recipient_user = self.example_user('hamlet')
content = 'x' * 15000
result = internal_prep_private_message(
realm=realm,
sender=sender,
recipient_user=recipient_user,
content=content)
message = result['message']
self.assertIn('message was too long', message.content)
class ExtractedRecipientsTest(TestCase):
def test_extract_recipients(self) -> None: