From 74943b4120fc341a7bf628c9c2105c0d58876de4 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 28 Oct 2017 08:52:15 -0700 Subject: [PATCH] tests: Fix send_message calls in test_notifications.py. --- zerver/tests/test_notifications.py | 128 +++++++++++++++++------------ 1 file changed, 75 insertions(+), 53 deletions(-) diff --git a/zerver/tests/test_notifications.py b/zerver/tests/test_notifications.py index a54336a5fc..0b6049b812 100644 --- a/zerver/tests/test_notifications.py +++ b/zerver/tests/test_notifications.py @@ -66,9 +66,13 @@ class TestMissedMessages(ZulipTestCase): mock_random_token.side_effect = tokens for i in range(0, 11): - self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, str(i)) - self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, '11', subject='test2') - msg_id = self.send_message(self.example_email('othello'), "denmark", Recipient.STREAM, '@**King Hamlet**') + self.send_stream_message(self.example_email('othello'), "Denmark", content=str(i)) + self.send_stream_message( + self.example_email('othello'), "Denmark", + '11', topic_name='test2') + msg_id = self.send_stream_message( + self.example_email('othello'), "denmark", + '@**King Hamlet**') body = 'Denmark > test Othello, the Moor of Venice 1 2 3 4 5 6 7 8 9 10 @**King Hamlet**' subject = 'Othello, the Moor of Venice mentioned you' self._test_cases(tokens, msg_id, body, subject, send_as_user) @@ -80,8 +84,10 @@ class TestMissedMessages(ZulipTestCase): mock_random_token.side_effect = tokens for i in range(0, 3): - self.send_message(self.example_email('cordelia'), "Denmark", Recipient.STREAM, str(i)) - msg_id = self.send_message(self.example_email('othello'), "Denmark", Recipient.STREAM, '@**King Hamlet**') + self.send_stream_message(self.example_email('cordelia'), "Denmark", str(i)) + msg_id = self.send_stream_message( + self.example_email('othello'), "Denmark", + '@**King Hamlet**') body = 'Denmark > test Cordelia Lear 0 1 2 Othello, the Moor of Venice @**King Hamlet**' subject = 'Othello, the Moor of Venice mentioned you' self._test_cases(tokens, msg_id, body, subject, send_as_user) @@ -92,9 +98,11 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'), - Recipient.PERSONAL, - 'Extremely personal message!') + msg_id = self.send_personal_message( + self.example_email('othello'), + self.example_email('hamlet'), + 'Extremely personal message!', + ) body = 'You and Othello, the Moor of Venice Extremely personal message!' subject = 'Othello, the Moor of Venice sent you a message' self._test_cases(tokens, msg_id, body, subject, send_as_user) @@ -105,9 +113,11 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'), - Recipient.PERSONAL, - 'Extremely personal message!') + msg_id = self.send_personal_message( + self.example_email('othello'), + self.example_email('hamlet'), + 'Extremely personal message!', + ) body = 'Or just reply to this email.' subject = 'Othello, the Moor of Venice sent you a message' self._test_cases(tokens, msg_id, body, subject, send_as_user) @@ -118,9 +128,11 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'), - Recipient.PERSONAL, - 'Extremely personal message!') + msg_id = self.send_personal_message( + self.example_email('othello'), + self.example_email('hamlet'), + 'Extremely personal message!', + ) body = 'Please do not reply to this automated message.' subject = 'Othello, the Moor of Venice sent you a message' self._test_cases(tokens, msg_id, body, subject, send_as_user) @@ -131,10 +143,14 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), - [self.example_email('hamlet'), self.example_email('iago')], - Recipient.HUDDLE, - 'Group personal message!') + msg_id = self.send_huddle_message( + self.example_email('othello'), + [ + self.example_email('hamlet'), + self.example_email('iago'), + ], + 'Group personal message!', + ) body = ('You and Iago, Othello, the Moor of Venice Othello,' ' the Moor of Venice Group personal message') @@ -147,10 +163,15 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), - [self.example_email('hamlet'), self.example_email('iago'), self.example_email('cordelia')], - Recipient.HUDDLE, - 'Group personal message!') + msg_id = self.send_huddle_message( + self.example_email('othello'), + [ + self.example_email('hamlet'), + self.example_email('iago'), + self.example_email('cordelia'), + ], + 'Group personal message!', + ) body = ('You and Cordelia Lear, Iago, Othello, the Moor of Venice Othello,' ' the Moor of Venice Group personal message') @@ -163,13 +184,12 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), - [self.example_email('hamlet'), - self.example_email('iago'), - self.example_email('cordelia'), - self.example_email('prospero')], - Recipient.HUDDLE, - 'Group personal message!') + msg_id = self.send_huddle_message(self.example_email('othello'), + [self.example_email('hamlet'), + self.example_email('iago'), + self.example_email('cordelia'), + self.example_email('prospero')], + 'Group personal message!') body = ('You and Cordelia Lear, Iago, Othello, the Moor of Venice, Prospero from The Tempest' ' Othello, the Moor of Venice Group personal message') @@ -182,8 +202,9 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), "denmark", Recipient.STREAM, - '@**King Hamlet** to be deleted') + msg_id = self.send_stream_message( + self.example_email('othello'), "denmark", + '@**King Hamlet** to be deleted') hamlet = self.example_user('hamlet') email = self.example_email('othello') @@ -200,10 +221,9 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), - self.example_email('hamlet'), - Recipient.PERSONAL, - 'Extremely personal message! to be deleted!') + msg_id = self.send_personal_message(self.example_email('othello'), + self.example_email('hamlet'), + 'Extremely personal message! to be deleted!') hamlet = self.example_user('hamlet') email = self.example_email('othello') @@ -220,10 +240,14 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), - [self.example_email('hamlet'), - self.example_email('iago')], - Recipient.PERSONAL, 'Group personal message!') + msg_id = self.send_huddle_message( + self.example_email('othello'), + [ + self.example_email('hamlet'), + self.example_email('iago'), + ], + 'Group personal message!', + ) hamlet = self.example_user('hamlet') iago = self.example_user('iago') @@ -333,9 +357,9 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'), - Recipient.PERSONAL, - 'Extremely personal message with a realm emoji :green_tick:!') + msg_id = self.send_personal_message( + self.example_email('othello'), self.example_email('hamlet'), + 'Extremely personal message with a realm emoji :green_tick:!') body = ':green_tick:' subject = 'Othello, the Moor of Venice sent you a message' self._test_cases(tokens, msg_id, body, subject, send_as_user=False, verify_html_body=True) @@ -346,9 +370,9 @@ class TestMissedMessages(ZulipTestCase): tokens = self._get_tokens() mock_random_token.side_effect = tokens - msg_id = self.send_message(self.example_email('othello'), self.example_email('hamlet'), - Recipient.PERSONAL, - 'Come and join us in #**Verona**.') + msg_id = self.send_personal_message( + self.example_email('othello'), self.example_email('hamlet'), + 'Come and join us in #**Verona**.') body = '#Verona