Example #1
0
 def send_message(self, message=None, **kwargs):
     response = notification_push(self.dev_type, self.reg_id, message, **kwargs)
     if 'success' in response:
         return response['success']
     elif 'canonical_id' in response:
         self.reg_id = response['canonical_id']
         self.save()
         return 'Message send successfully'
     elif 'error' in response:
         if response['error'] == 'NotRegistered':
             self.mark_inactive()
             return GCM_ERROR_MESSAGES[response['error']]
         else:
             return GCM_ERROR_MESSAGES.get(response['error'], response['error'])
 def test_notification_push_mock(self, mock_notification_push):
     mock_notification_push.return_value = 'Message send successfully'
     response = utils.notification_push('dev_type', 'to', 'message')
     self.assertEqual(response, 'Message send successfully')
 def test_notification_push_real(self):
     response = utils.notification_push('ANDROID',
                                        'to',
                                        'message')
     self.assertEqual(response, {'error': '400 Client Error: Bad Request'})
Example #4
0
 def test_notification_push_mock(self, mock_notification_push):
     mock_notification_push.return_value = 'Message send successfully'
     response = utils.notification_push('dev_type', 'to', 'message')
     self.assertEqual(response, 'Message send successfully')
Example #5
0
 def test_notification_push_real(self):
     response = utils.notification_push('ANDROID', 'to', 'message')
     self.assertEqual(response, {'error': '400 Client Error: Bad Request'})