1919
2020def _make_credentials ():
2121 import google .auth .credentials
22+
2223 return mock .Mock (spec = google .auth .credentials .Credentials )
2324
2425
@@ -27,6 +28,7 @@ class TestMIMEApplicationHTTP(unittest.TestCase):
2728 @staticmethod
2829 def _get_target_class ():
2930 from google .cloud .storage .batch import MIMEApplicationHTTP
31+
3032 return MIMEApplicationHTTP
3133
3234 def _make_one (self , * args , ** kw ):
@@ -79,6 +81,7 @@ class TestBatch(unittest.TestCase):
7981 @staticmethod
8082 def _get_target_class ():
8183 from google .cloud .storage .batch import Batch
84+
8285 return Batch
8386
8487 def _make_one (self , * args , ** kw ):
@@ -95,6 +98,7 @@ def test_ctor(self):
9598
9699 def test_current (self ):
97100 from google .cloud .storage .client import Client
101+
98102 project = 'PROJECT'
99103 credentials = _make_credentials ()
100104 client = Client (project = project , credentials = credentials )
@@ -110,6 +114,7 @@ def test_current(self):
110114
111115 def test__make_request_GET_normal (self ):
112116 from google .cloud .storage .batch import _FutureDict
117+
113118 URL = 'http://example.com/api'
114119 expected = _Response ()
115120 http = _HTTP ((expected , '' ))
@@ -136,6 +141,7 @@ def test__make_request_GET_normal(self):
136141
137142 def test__make_request_POST_normal (self ):
138143 from google .cloud .storage .batch import _FutureDict
144+
139145 URL = 'http://example.com/api'
140146 http = _HTTP () # no requests expected
141147 connection = _Connection (http = http )
@@ -161,6 +167,7 @@ def test__make_request_POST_normal(self):
161167
162168 def test__make_request_PATCH_normal (self ):
163169 from google .cloud .storage .batch import _FutureDict
170+
164171 URL = 'http://example.com/api'
165172 http = _HTTP () # no requests expected
166173 connection = _Connection (http = http )
@@ -186,6 +193,7 @@ def test__make_request_PATCH_normal(self):
186193
187194 def test__make_request_DELETE_normal (self ):
188195 from google .cloud .storage .batch import _FutureDict
196+
189197 URL = 'http://example.com/api'
190198 http = _HTTP () # no requests expected
191199 connection = _Connection (http = http )
@@ -241,6 +249,7 @@ def _check_subrequest_no_payload(self, chunk, method, url):
241249
242250 def _check_subrequest_payload (self , chunk , method , url , payload ):
243251 import json
252+
244253 lines = chunk .splitlines ()
245254 # blank + 2 headers + blank + request + 2 headers + blank + body
246255 payload_str = json .dumps (payload )
@@ -262,6 +271,7 @@ def _check_subrequest_payload(self, chunk, method, url, payload):
262271
263272 def test_finish_nonempty (self ):
264273 import httplib2
274+
265275 URL = 'http://api.example.com/other_api'
266276 expected = _Response ()
267277 expected ['content-type' ] = 'multipart/mixed; boundary="DEADBEEF="'
@@ -325,6 +335,7 @@ def test_finish_responses_mismatch(self):
325335
326336 def test_finish_nonempty_with_status_failure (self ):
327337 from google .cloud .exceptions import NotFound
338+
328339 URL = 'http://api.example.com/other_api'
329340 expected = _Response ()
330341 expected ['content-type' ] = 'multipart/mixed; boundary="DEADBEEF="'
@@ -380,6 +391,7 @@ def test_finish_nonempty_non_multipart_response(self):
380391
381392 def test_as_context_mgr_wo_error (self ):
382393 from google .cloud .storage .client import Client
394+
383395 URL = 'http://example.com/api'
384396 expected = _Response ()
385397 expected ['content-type' ] = 'multipart/mixed; boundary="DEADBEEF="'
@@ -417,6 +429,7 @@ def test_as_context_mgr_wo_error(self):
417429 def test_as_context_mgr_w_error (self ):
418430 from google .cloud .storage .batch import _FutureDict
419431 from google .cloud .storage .client import Client
432+
420433 URL = 'http://example.com/api'
421434 http = _HTTP ()
422435 connection = _Connection (http = http )
@@ -457,10 +470,12 @@ class Test__unpack_batch_response(unittest.TestCase):
457470
458471 def _call_fut (self , response , content ):
459472 from google .cloud .storage .batch import _unpack_batch_response
473+
460474 return _unpack_batch_response (response , content )
461475
462476 def _unpack_helper (self , response , content ):
463477 import httplib2
478+
464479 result = list (self ._call_fut (response , content ))
465480 self .assertEqual (len (result ), 3 )
466481 response0 = httplib2 .Response ({
@@ -548,6 +563,7 @@ class Test__FutureDict(unittest.TestCase):
548563
549564 def _make_one (self , * args , ** kw ):
550565 from google .cloud .storage .batch import _FutureDict
566+
551567 return _FutureDict (* args , ** kw )
552568
553569 def test_get (self ):
@@ -580,14 +596,12 @@ def _make_request(self, method, url, data=None, headers=None):
580596
581597
582598class _Response (dict ):
583-
584599 def __init__ (self , status = 200 , ** kw ):
585600 self .status = status
586601 super (_Response , self ).__init__ (** kw )
587602
588603
589604class _HTTP (object ):
590-
591605 def __init__ (self , * responses ):
592606 self ._requests = []
593607 self ._responses = list (responses )
0 commit comments