Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion googleapiclient/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ def close(self):
# httplib2 leaves sockets open by default.
# Cleanup using the `close` method.
# https://github.com/httplib2/httplib2/issues/148
self._http.http.close()
self._http.close()

def _set_service_methods(self):
self._add_basic_methods(self._resourceDesc, self._rootDesc, self._schema)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
install_requires = [
"httplib2>=0.15.0,<1dev",
"google-auth>=1.16.0,<2dev",
"google-auth-httplib2>=0.0.3",
"google-auth-httplib2>=0.1.0",
"google-api-core>=1.21.0,<2dev",
"six>=1.13.0,<2dev",
"uritemplate>=3.0.0,<4dev",
Expand Down
18 changes: 16 additions & 2 deletions tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
from oauth2client import GOOGLE_TOKEN_URI
from oauth2client.client import OAuth2Credentials, GoogleCredentials


from googleapiclient import _helpers as util

import uritemplate
Expand Down Expand Up @@ -591,14 +592,27 @@ def test_building_with_context_manager(self):

def test_resource_close(self):
discovery = read_datafile("plus.json")
with mock.patch("httplib2.Http") as http:

with mock.patch("httplib2.Http", autospec=True) as httplib2_http:
http = httplib2_http()
plus = build_from_document(
discovery,
base="https://www.googleapis.com/",
http=http,
)
plus.close()
http.close.assert_called_once()

def test_resource_close_authorized_http(self):
discovery = read_datafile("plus.json")
with mock.patch("google_auth_httplib2.AuthorizedHttp", autospec=True):
plus = build_from_document(
discovery,
base="https://www.googleapis.com/",
credentials=self.MOCK_CREDENTIALS,
)
plus.close()
plus._http.http.close.assert_called_once()
plus._http.close.assert_called_once()

def test_api_endpoint_override_from_client_options(self):
discovery = read_datafile("plus.json")
Expand Down