diff --git a/packages/google-cloud-speech/google/cloud/speech/client.py b/packages/google-cloud-speech/google/cloud/speech/client.py index 7c066d48cb9d..df0bee95461b 100644 --- a/packages/google-cloud-speech/google/cloud/speech/client.py +++ b/packages/google-cloud-speech/google/cloud/speech/client.py @@ -39,10 +39,10 @@ class Client(BaseClient): passed), falls back to the default inferred from the environment. - :type _http: :class:`~httplib2.Http` + :type _http: :class:`~requests.Session` :param _http: (Optional) HTTP object to make requests. Can be any object that defines ``request()`` with the same interface as - :meth:`~httplib2.Http.request`. If not passed, an + :meth:`requests.Session.request`. If not passed, an ``_http`` object is created that is bound to the ``credentials`` for the current object. This parameter should be considered private, and could diff --git a/packages/google-cloud-speech/tests/unit/test__http.py b/packages/google-cloud-speech/tests/unit/test__http.py index fd39428ffdbb..4aa7613910e9 100644 --- a/packages/google-cloud-speech/tests/unit/test__http.py +++ b/packages/google-cloud-speech/tests/unit/test__http.py @@ -40,13 +40,17 @@ def test_build_api_url(self): self.assertEqual(conn.build_api_url(method), uri) def test_extra_headers(self): + import requests + from google.cloud import _http as base_http from google.cloud.speech import _http as MUT - http = mock.Mock(spec=['request']) - response = mock.Mock(status=200, spec=['status']) + http = mock.create_autospec(requests.Session, instance=True) + response = requests.Response() + response.status_code = 200 data = b'brent-spiner' - http.request.return_value = response, data + response._content = data + http.request.return_value = response client = mock.Mock(_http=http, spec=['_http']) conn = self._make_one(client) @@ -56,12 +60,14 @@ def test_extra_headers(self): self.assertEqual(result, data) expected_headers = { - 'Content-Length': str(len(req_data)), 'Accept-Encoding': 'gzip', base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO, 'User-Agent': conn.USER_AGENT, } expected_uri = conn.build_api_url('/rainbow') http.request.assert_called_once_with( - body=req_data, headers=expected_headers, method='GET', - uri=expected_uri) + data=req_data, + headers=expected_headers, + method='GET', + url=expected_uri, + )