コード例 #1
0
 def test_send_with_no_api_key(self):
     # Check that we throw the proper exception
     # in case no API Key is specified
     with mock.patch('django.conf.settings.PUSHY_GCM_API_KEY', new=None):
         dispatcher = dispatchers.GCMDispatcher()
         self.assertRaises(PushAuthException, dispatcher.send,
                           self.device_key, self.data)
コード例 #2
0
 def test_invalid_token_exception(self):
     dispatcher = dispatchers.GCMDispatcher()
     # Check not registered exception
     response_mock = mock.Mock()
     response_mock.return_value = invalid_with_exception(GCMAuthError(''))
     with mock.patch('pushjack.GCMClient.send', new=response_mock):
         self.assertRaises(PushAuthException, dispatcher.send,
                           self.device_key, self.data)
コード例 #3
0
 def test_notification_sent_with_canonical_id(self):
     dispatcher = dispatchers.GCMDispatcher()
     # Check result when canonical value is returned
     response_mock = mock.Mock()
     response_mock.return_value = valid_with_canonical_id_response(123123)
     with mock.patch('pushjack.GCMClient.send', new=response_mock):
         canonical_id = dispatcher.send(self.device_key, self.data)
         self.assertEquals(canonical_id, 123123)
コード例 #4
0
 def test_notification_sent(self):
     dispatcher = dispatchers.GCMDispatcher()
     with mock.patch('pushjack.GCMClient.send') as request_mock:
         request_mock.return_value = valid_response()
         dispatcher.send(self.device_key, self.data)
         self.assertTrue(request_mock.called)
コード例 #5
0
 def test_constructor_with_api_key(self):
     dispatcher = dispatchers.GCMDispatcher(123)
     self.assertEquals(123, dispatcher._api_key)