Пример #1
0
 def test_googleapicleint_timeout_error(self, error):
     firebase_error = _utils.handle_googleapiclient_error(error)
     assert isinstance(firebase_error, exceptions.DeadlineExceededError)
     assert str(firebase_error
                ) == 'Timed out while making an API call: {0}'.format(error)
     assert firebase_error.cause is error
     assert firebase_error.http_response is None
Пример #2
0
 def test_http_response_with_unknown_status(self):
     error = self._create_http_error(status=501)
     firebase_error = _utils.handle_googleapiclient_error(error)
     assert isinstance(firebase_error, exceptions.UnknownError)
     assert str(firebase_error) == str(error)
     assert firebase_error.cause is error
     assert firebase_error.http_response.status_code == 501
     assert firebase_error.http_response.content.decode() == 'Body'
Пример #3
0
 def test_http_response(self):
     error = self._create_http_error()
     firebase_error = _utils.handle_googleapiclient_error(error)
     assert isinstance(firebase_error, exceptions.InternalError)
     assert str(firebase_error) == str(error)
     assert firebase_error.cause is error
     assert firebase_error.http_response.status_code == 500
     assert firebase_error.http_response.content.decode() == 'Body'
Пример #4
0
 def test_googleapiclient_connection_error(self):
     error = httplib2.ServerNotFoundError('Test error')
     firebase_error = _utils.handle_googleapiclient_error(error)
     assert isinstance(firebase_error, exceptions.UnavailableError)
     assert str(
         firebase_error) == 'Failed to establish a connection: Test error'
     assert firebase_error.cause is error
     assert firebase_error.http_response is None
Пример #5
0
 def test_unknown_transport_error(self):
     error = socket.error('Test error')
     firebase_error = _utils.handle_googleapiclient_error(error)
     assert isinstance(firebase_error, exceptions.UnknownError)
     assert str(
         firebase_error
     ) == 'Unknown error while making a remote service call: Test error'
     assert firebase_error.cause is error
     assert firebase_error.http_response is None
Пример #6
0
 def test_http_response_with_message_and_code(self):
     error = self._create_http_error()
     firebase_error = _utils.handle_googleapiclient_error(
         error,
         message='Explicit error message',
         code=exceptions.UNAVAILABLE)
     assert isinstance(firebase_error, exceptions.UnavailableError)
     assert str(firebase_error) == 'Explicit error message'
     assert firebase_error.cause is error
     assert firebase_error.http_response.status_code == 500
     assert firebase_error.http_response.content.decode() == 'Body'