mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	push_notifications: Catch IOError while pushing to GCM.
This commit is contained in:
		| @@ -242,7 +242,11 @@ def send_android_push_notification(devices, data, remote=False): | ||||
|     else: | ||||
|         DeviceTokenClass = PushDeviceToken | ||||
|  | ||||
|     try: | ||||
|         res = gcm.json_request(registration_ids=reg_ids, data=data) | ||||
|     except IOError as e: | ||||
|         logging.warning(str(e)) | ||||
|         return | ||||
|  | ||||
|     if res and 'success' in res: | ||||
|         for reg_id, msg_id in res['success'].items(): | ||||
|   | ||||
| @@ -790,6 +790,15 @@ class GCMNotSetTest(GCMTest): | ||||
|                                         "notification, but no API key was " | ||||
|                                         "configured") | ||||
|  | ||||
| class GCMIOErrorTest(GCMTest): | ||||
|     @mock.patch('zerver.lib.push_notifications.gcm.json_request') | ||||
|     @mock.patch('logging.warning') | ||||
|     def test_json_request_raises_ioerror(self, mock_warn, mock_json_request): | ||||
|         # type: (mock.MagicMock, mock.MagicMock) -> None | ||||
|         mock_json_request.side_effect = IOError('error') | ||||
|         apn.send_android_push_notification_to_user(self.user_profile, {}) | ||||
|         mock_warn.assert_called_with('error') | ||||
|  | ||||
| class GCMSuccessTest(GCMTest): | ||||
|     @mock.patch('logging.warning') | ||||
|     @mock.patch('logging.info') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user