From 2bc34bb3ff8ca54b585e472e5a33cef58f1e6b7c Mon Sep 17 00:00:00 2001 From: Hashir Sarwar Date: Tue, 16 Jun 2020 09:32:34 +0500 Subject: [PATCH] test_push_notifications: Remove mocking of `get_base_payload()`. Mocking `get_base_payload()` verifies the wrong output when the code is actually correct. So, its better that we call the real function here, especially when we are adding the Apple case. --- zerver/tests/test_push_notifications.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index ce901da49b..9482d29e57 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -923,15 +923,16 @@ class HandlePushNotificationTest(PushNotificationTest): with self.settings(PUSH_NOTIFICATION_BOUNCER_URL=True), \ mock.patch('zerver.lib.push_notifications' - '.send_notifications_to_bouncer') as mock_send_android, \ - mock.patch('zerver.lib.push_notifications.get_base_payload', - return_value={'gcm': True}): + '.send_notifications_to_bouncer') as mock_send_android: handle_remove_push_notification(user_profile.id, [message.id]) mock_send_android.assert_called_with( user_profile.id, {}, { - 'gcm': True, + 'server': 'testserver', + 'realm_id': self.sender.realm.id, + 'realm_uri': 'http://zulip.testserver', + 'user_id': self.user_profile.id, 'event': 'remove', 'zulip_message_ids': str(message.id), 'zulip_message_id': message.id, @@ -956,14 +957,15 @@ class HandlePushNotificationTest(PushNotificationTest): kind=PushDeviceToken.GCM)) with mock.patch('zerver.lib.push_notifications' - '.send_android_push_notification') as mock_send_android, \ - mock.patch('zerver.lib.push_notifications.get_base_payload', - return_value={'gcm': True}): + '.send_android_push_notification') as mock_send_android: handle_remove_push_notification(self.user_profile.id, [message.id]) mock_send_android.assert_called_with( android_devices, { - 'gcm': True, + 'server': 'testserver', + 'realm_id': self.sender.realm.id, + 'realm_uri': 'http://zulip.testserver', + 'user_id': self.user_profile.id, 'event': 'remove', 'zulip_message_ids': str(message.id), 'zulip_message_id': message.id,