Skip to content

Commit 760f7fc

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 b4f135c commit 760f7fc

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

packages/google-cloud-monitoring/google/cloud/monitoring/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class Client(ClientWithProject):
6262
passed), falls back to the default inferred from the
6363
environment.
6464
65-
:type _http: :class:`~httplib2.Http`
65+
:type _http: :class:`~requests.Session`
6666
:param _http: (Optional) HTTP object to make requests. Can be any object
6767
that defines ``request()`` with the same interface as
68-
:meth:`~httplib2.Http.request`. If not passed, an
68+
:meth:`requests.Session.request`. If not passed, an
6969
``_http`` object is created that is bound to the
7070
``credentials`` for the current object.
7171
This parameter should be considered private, and could

packages/google-cloud-monitoring/tests/unit/test__http.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ def test_constructor(self):
3434
self.assertIs(connection._client, client)
3535

3636
def test_extra_headers(self):
37+
import requests
38+
3739
from google.cloud import _http as base_http
3840
from google.cloud.monitoring import _http as MUT
3941

40-
http = mock.Mock(spec=['request'])
41-
response = mock.Mock(status=200, spec=['status'])
42+
http = mock.create_autospec(requests.Session, instance=True)
43+
response = requests.Response()
44+
response.status_code = 200
4245
data = b'brent-spiner'
43-
http.request.return_value = response, data
46+
response._content = data
47+
http.request.return_value = response
4448
client = mock.Mock(_http=http, spec=['_http'])
4549

4650
conn = self._make_one(client)
@@ -50,15 +54,14 @@ def test_extra_headers(self):
5054
self.assertEqual(result, data)
5155

5256
expected_headers = {
53-
'Content-Length': str(len(req_data)),
5457
'Accept-Encoding': 'gzip',
5558
base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO,
5659
'User-Agent': conn.USER_AGENT,
5760
}
5861
expected_uri = conn.build_api_url('/rainbow')
5962
http.request.assert_called_once_with(
60-
body=req_data,
63+
data=req_data,
6164
headers=expected_headers,
6265
method='GET',
63-
uri=expected_uri,
66+
url=expected_uri,
6467
)

0 commit comments

Comments
 (0)