Skip to content

Commit 57ea25c

Browse files
author
Jon Wayne Parrott
authored
Remove httplib2, replace with Requests (#3674)
* Core: remove httplib2, replace with Requests Additionally remove make_exception in favor of from_http_status and from_http_response. * Datastore: replace httplib2 with Requests * DNS: replace httplib2 with Requests * Error Reporting: replace httplib2 with requests * Language: replace httplib2 with Requests * Logging: replace httplib2 with requests * Monitoring: replace httplib2 with Requests * Pubsub: replace httplib2 with Requests * Resource Manager: replace httplib2 with Requests * Runtimeconfig: replace httplib2 with Requests * Speech: replace httplib2 with Requests * Storage: replace httplib2 with Requests * BigQuery: replace httplib2 with Requests * Translate: replace httplib2 with Requests * Vision: replace httplib2 with Requests
1 parent 12e65d8 commit 57ea25c

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

google-cloud-speech/google/cloud/speech/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class Client(BaseClient):
3939
passed), falls back to the default inferred from the
4040
environment.
4141
42-
:type _http: :class:`~httplib2.Http`
42+
:type _http: :class:`~requests.Session`
4343
:param _http: (Optional) HTTP object to make requests. Can be any object
4444
that defines ``request()`` with the same interface as
45-
:meth:`~httplib2.Http.request`. If not passed, an
45+
:meth:`requests.Session.request`. If not passed, an
4646
``_http`` object is created that is bound to the
4747
``credentials`` for the current object.
4848
This parameter should be considered private, and could

google-cloud-speech/tests/unit/test__http.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ def test_build_api_url(self):
4040
self.assertEqual(conn.build_api_url(method), uri)
4141

4242
def test_extra_headers(self):
43+
import requests
44+
4345
from google.cloud import _http as base_http
4446
from google.cloud.speech import _http as MUT
4547

46-
http = mock.Mock(spec=['request'])
47-
response = mock.Mock(status=200, spec=['status'])
48+
http = mock.create_autospec(requests.Session, instance=True)
49+
response = requests.Response()
50+
response.status_code = 200
4851
data = b'brent-spiner'
49-
http.request.return_value = response, data
52+
response._content = data
53+
http.request.return_value = response
5054
client = mock.Mock(_http=http, spec=['_http'])
5155

5256
conn = self._make_one(client)
@@ -56,12 +60,14 @@ def test_extra_headers(self):
5660
self.assertEqual(result, data)
5761

5862
expected_headers = {
59-
'Content-Length': str(len(req_data)),
6063
'Accept-Encoding': 'gzip',
6164
base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO,
6265
'User-Agent': conn.USER_AGENT,
6366
}
6467
expected_uri = conn.build_api_url('/rainbow')
6568
http.request.assert_called_once_with(
66-
body=req_data, headers=expected_headers, method='GET',
67-
uri=expected_uri)
69+
data=req_data,
70+
headers=expected_headers,
71+
method='GET',
72+
url=expected_uri,
73+
)

0 commit comments

Comments
 (0)