示例#1
0
 def _assert_raises_HTTPError_with_extras(self, code):
     pusher = Pusher()
     resp = self._create_mocked_response(code=code)
     try:
         pusher._processErrorResponse(resp)
         self.assertFail()
     except HTTPError as error:
         self.assertEqual(code, error.extra['response code'])
         if code in Pusher.RESPONSE_TO_ERROR:
             self.assertEqual(Pusher.RESPONSE_TO_ERROR[code], error.message)
         else:
             self.assertEqual('Unknown response code', error.message)
示例#2
0
 def _assert_raises_HTTPError_with_extras(self, code):
     pusher = Pusher()
     resp = self._create_mocked_response(code=code)
     try:
         pusher._processErrorResponse(resp)
         self.assertFail()
     except HTTPError as error:
         self.assertEqual(code, error.extra['response code'])
         if code in Pusher.RESPONSE_TO_ERROR:
             self.assertEqual(Pusher.RESPONSE_TO_ERROR[code],
                              error.message)
         else:
             self.assertEqual('Unknown response code', error.message)
示例#3
0
    def test_send_unprocessable(self):
        pusher = Pusher()
        notification = self._create_mocked_notification()
        response = self._create_mocked_response(code=400)

        pusher._agent.request = Mock(return_value=response)
        pusher._processResponse = Mock()
        pusher._processErrorResponse = Mock()

        pusher.send(notification)

        pusher._processErrorResponse.assert_called_once_with(response)
        self.assertFalse(pusher._processResponse.called)
示例#4
0
    def test_send_unprocessable(self):
        pusher = Pusher()
        notification = self._create_mocked_notification()
        response = self._create_mocked_response(code=400)

        pusher._agent.request = Mock(return_value=response)
        pusher._processResponse = Mock()
        pusher._processErrorResponse = Mock()

        pusher.send(notification)

        pusher._processErrorResponse.assert_called_once_with(response)
        self.assertFalse(pusher._processResponse.called)