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(
254254 A Resource object with methods for interacting with the service.
255255 """
256256
257+ if http is None :
258+ http = httplib2 .Http ()
259+
257260 # future is no longer used.
258261 future = {}
259262
Original file line number Diff line number Diff line change @@ -366,6 +366,17 @@ def test_building_with_base_remembers_base(self):
366366 plus = build_from_document (discovery , base = base )
367367 self .assertEquals ("https://www.googleapis.com/plus/v1/" , plus ._baseUrl )
368368
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 )
369380
370381class DiscoveryFromHttp (unittest .TestCase ):
371382 def setUp (self ):
You can’t perform that action at this time.
0 commit comments