From b8c8ea526209e93dca9bcdcf7cace171a08016ce Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Tue, 2 Feb 2021 14:09:11 +0100 Subject: [PATCH] tests: Fix bugs confusing recipient.type_id for other ids. These tests were accidentally passing due to numbers coinciding. --- zerver/tests/test_email_mirror.py | 2 +- zerver/tests/test_message_send.py | 2 +- zerver/tests/test_outgoing_webhook_system.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py index 95ed80197e..ae36367402 100644 --- a/zerver/tests/test_email_mirror.py +++ b/zerver/tests/test_email_mirror.py @@ -761,7 +761,7 @@ class TestMissedMessageEmailMessages(ZulipTestCase): self.assertEqual(message.content, "TestMissedMessageEmailMessages Body") self.assertEqual(message.sender, self.example_user('othello')) - self.assertEqual(message.recipient.id, user_profile.id) + self.assertEqual(message.recipient.type_id, user_profile.id) self.assertEqual(message.recipient.type, Recipient.PERSONAL) def test_receive_missed_huddle_message_email_messages(self) -> None: diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 724f5312fe..b2ab3b13e3 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -371,7 +371,7 @@ class MessagePOSTTest(ZulipTestCase): msg = self.get_last_message() self.assertEqual("Test message", msg.content) - self.assertEqual(msg.recipient_id, self.example_user("othello").id) + self.assertEqual(msg.recipient_id, self.example_user("othello").recipient_id) def test_group_personal_message_by_id(self) -> None: """ diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py index 334a2415c8..3b06a727ec 100644 --- a/zerver/tests/test_outgoing_webhook_system.py +++ b/zerver/tests/test_outgoing_webhook_system.py @@ -86,7 +86,7 @@ class DoRestCallTests(ZulipTestCase): The webhook got a response with status code *500*.''') assert bot_user.bot_owner is not None - self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.id) + self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id) def test_fail_request(self) -> None: bot_user = self.example_user('outgoing_webhook_bot') @@ -111,7 +111,7 @@ The webhook got a response with status code *500*.''') The webhook got a response with status code *400*.''') assert bot_user.bot_owner is not None - self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.id) + self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id) def test_headers(self) -> None: bot_user = self.example_user('outgoing_webhook_bot') @@ -149,7 +149,7 @@ The webhook got a response with status code *400*.''') self.assertIn(error_text, bot_owner_notification.content) self.assertIn('triggered', bot_owner_notification.content) assert bot_user.bot_owner is not None - self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.id) + self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id) with self.assertLogs(level="INFO") as i: helper(side_effect=timeout_error, error_text='A timeout occurred.') @@ -188,7 +188,7 @@ When trying to send a request to the webhook service, an exception of type Reque I'm a generic exception :( ```''') assert bot_user.bot_owner is not None - self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.id) + self.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id) class TestOutgoingWebhookMessaging(ZulipTestCase): def create_outgoing_bot(self, bot_owner: UserProfile) -> UserProfile: