File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,9 @@ def build_from_document(
254
254
A Resource object with methods for interacting with the service.
255
255
"""
256
256
257
+ if http is None :
258
+ http = httplib2 .Http ()
259
+
257
260
# future is no longer used.
258
261
future = {}
259
262
Original file line number Diff line number Diff line change @@ -366,6 +366,17 @@ def test_building_with_base_remembers_base(self):
366
366
plus = build_from_document (discovery , base = base )
367
367
self .assertEquals ("https://www.googleapis.com/plus/v1/" , plus ._baseUrl )
368
368
369
+ def test_building_with_optional_http (self ):
370
+ discovery = open (datafile ('plus.json' )).read ()
371
+ plus = build_from_document (discovery , base = "https://www.googleapis.com/" )
372
+ self .assertTrue (isinstance (plus ._http , httplib2 .Http ))
373
+
374
+ def test_building_with_explicit_http (self ):
375
+ http = HttpMock ()
376
+ discovery = open (datafile ('plus.json' )).read ()
377
+ plus = build_from_document (
378
+ discovery , base = "https://www.googleapis.com/" , http = http )
379
+ self .assertEquals (plus ._http , http )
369
380
370
381
class DiscoveryFromHttp (unittest .TestCase ):
371
382
def setUp (self ):
You can’t perform that action at this time.
0 commit comments