push notif tests: Use mock.patch instead of `apn.gcm = None`.

This is what it's for -- and it cleans up after itself, too.
This commit is contained in:
Greg Price 2019-02-08 13:59:38 -08:00 committed by Tim Abbott
parent ff12072f18
commit e289c5835d
1 changed files with 3 additions and 2 deletions

View File

@ -1367,8 +1367,9 @@ class GCMSendTest(PushNotificationTest):
return data return data
@mock.patch('zerver.lib.push_notifications.logger.debug') @mock.patch('zerver.lib.push_notifications.logger.debug')
def test_gcm_is_none(self, mock_debug: mock.MagicMock) -> None: @mock.patch('zerver.lib.push_notifications.gcm')
apn.gcm = None def test_gcm_is_none(self, mock_gcm: mock.MagicMock, mock_debug: mock.MagicMock) -> None:
mock_gcm.__bool__.return_value = False
apn.send_android_push_notification_to_user(self.user_profile, {}, {}) apn.send_android_push_notification_to_user(self.user_profile, {}, {})
mock_debug.assert_called_with( mock_debug.assert_called_with(
"Skipping sending a GCM push notification since PUSH_NOTIFICATION_BOUNCER_URL " "Skipping sending a GCM push notification since PUSH_NOTIFICATION_BOUNCER_URL "