Skip to content

Commit 344a058

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 e941cc7 commit 344a058

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/google-cloud-resource-manager/google/cloud/resource_manager/client.py

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

packages/google-cloud-resource-manager/tests/unit/test__http.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ def test_build_api_url_w_extra_query_params(self):
5151
self.assertEqual(parms['bar'], 'baz')
5252

5353
def test_extra_headers(self):
54+
import requests
55+
5456
from google.cloud import _http as base_http
5557
from google.cloud.resource_manager import _http as MUT
5658

57-
http = mock.Mock(spec=['request'])
58-
response = mock.Mock(status=200, spec=['status'])
59+
http = mock.create_autospec(requests.Session, instance=True)
60+
response = requests.Response()
61+
response.status_code = 200
5962
data = b'brent-spiner'
60-
http.request.return_value = response, data
63+
response._content = data
64+
http.request.return_value = response
6165
client = mock.Mock(_http=http, spec=['_http'])
6266

6367
conn = self._make_one(client)
@@ -67,15 +71,14 @@ def test_extra_headers(self):
6771
self.assertEqual(result, data)
6872

6973
expected_headers = {
70-
'Content-Length': str(len(req_data)),
7174
'Accept-Encoding': 'gzip',
7275
base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO,
7376
'User-Agent': conn.USER_AGENT,
7477
}
7578
expected_uri = conn.build_api_url('/rainbow')
7679
http.request.assert_called_once_with(
77-
body=req_data,
80+
data=req_data,
7881
headers=expected_headers,
7982
method='GET',
80-
uri=expected_uri,
83+
url=expected_uri,
8184
)

0 commit comments

Comments
 (0)