@@ -184,23 +184,23 @@ def test_get_bucket_hit(self):
184184 CREDENTIALS = _make_credentials ()
185185 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
186186
187- BLOB_NAME = 'blob -name'
187+ BUCKET_NAME = 'bucket -name'
188188 URI = '/' .join ([
189189 client ._connection .API_BASE_URL ,
190190 'storage' ,
191191 client ._connection .API_VERSION ,
192192 'b' ,
193- '%s?projection=noAcl' % (BLOB_NAME ,),
193+ '%s?projection=noAcl' % (BUCKET_NAME ,),
194194 ])
195195
196- data = {'name' : BLOB_NAME }
196+ data = {'name' : BUCKET_NAME }
197197 http = _make_requests_session ([_make_json_response (data )])
198198 client ._http_internal = http
199199
200- bucket = client .get_bucket (BLOB_NAME )
200+ bucket = client .get_bucket (BUCKET_NAME )
201201
202202 self .assertIsInstance (bucket , Bucket )
203- self .assertEqual (bucket .name , BLOB_NAME )
203+ self .assertEqual (bucket .name , BUCKET_NAME )
204204 http .request .assert_called_once_with (
205205 method = 'GET' , url = URI , data = mock .ANY , headers = mock .ANY )
206206
@@ -234,22 +234,22 @@ def test_lookup_bucket_hit(self):
234234 CREDENTIALS = _make_credentials ()
235235 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
236236
237- BLOB_NAME = 'blob -name'
237+ BUCKET_NAME = 'bucket -name'
238238 URI = '/' .join ([
239239 client ._connection .API_BASE_URL ,
240240 'storage' ,
241241 client ._connection .API_VERSION ,
242242 'b' ,
243- '%s?projection=noAcl' % (BLOB_NAME ,),
243+ '%s?projection=noAcl' % (BUCKET_NAME ,),
244244 ])
245- data = {'name' : BLOB_NAME }
245+ data = {'name' : BUCKET_NAME }
246246 http = _make_requests_session ([_make_json_response (data )])
247247 client ._http_internal = http
248248
249- bucket = client .lookup_bucket (BLOB_NAME )
249+ bucket = client .lookup_bucket (BUCKET_NAME )
250250
251251 self .assertIsInstance (bucket , Bucket )
252- self .assertEqual (bucket .name , BLOB_NAME )
252+ self .assertEqual (bucket .name , BUCKET_NAME )
253253 http .request .assert_called_once_with (
254254 method = 'GET' , url = URI , data = mock .ANY , headers = mock .ANY )
255255
@@ -260,21 +260,24 @@ def test_create_bucket_conflict(self):
260260 CREDENTIALS = _make_credentials ()
261261 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
262262
263- BLOB_NAME = 'blob -name'
263+ BUCKET_NAME = 'bucket -name'
264264 URI = '/' .join ([
265265 client ._connection .API_BASE_URL ,
266266 'storage' ,
267267 client ._connection .API_VERSION ,
268268 'b?project=%s' % (PROJECT ,),
269269 ])
270270 data = {'error' : {'message' : 'Conflict' }}
271+ sent = {'name' : BUCKET_NAME }
271272 http = _make_requests_session ([
272273 _make_json_response (data , status = http_client .CONFLICT )])
273274 client ._http_internal = http
274275
275- self .assertRaises (Conflict , client .create_bucket , BLOB_NAME )
276+ self .assertRaises (Conflict , client .create_bucket , BUCKET_NAME )
276277 http .request .assert_called_once_with (
277278 method = 'POST' , url = URI , data = mock .ANY , headers = mock .ANY )
279+ json_sent = http .request .call_args_list [0 ][1 ]['data' ]
280+ self .assertEqual (sent , json .loads (json_sent ))
278281
279282 def test_create_bucket_success (self ):
280283 from google .cloud .storage .bucket import Bucket
@@ -283,23 +286,27 @@ def test_create_bucket_success(self):
283286 CREDENTIALS = _make_credentials ()
284287 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
285288
286- BLOB_NAME = 'blob -name'
289+ BUCKET_NAME = 'bucket -name'
287290 URI = '/' .join ([
288291 client ._connection .API_BASE_URL ,
289292 'storage' ,
290293 client ._connection .API_VERSION ,
291294 'b?project=%s' % (PROJECT ,),
292295 ])
293- data = {'name' : BLOB_NAME }
296+ sent = {'name' : BUCKET_NAME , 'billing' : {'requesterPays' : True }}
297+ data = sent
294298 http = _make_requests_session ([_make_json_response (data )])
295299 client ._http_internal = http
296300
297- bucket = client .create_bucket (BLOB_NAME )
301+ bucket = client .create_bucket (BUCKET_NAME , requester_pays = True )
298302
299303 self .assertIsInstance (bucket , Bucket )
300- self .assertEqual (bucket .name , BLOB_NAME )
304+ self .assertEqual (bucket .name , BUCKET_NAME )
305+ self .assertTrue (bucket .requester_pays )
301306 http .request .assert_called_once_with (
302307 method = 'POST' , url = URI , data = mock .ANY , headers = mock .ANY )
308+ json_sent = http .request .call_args_list [0 ][1 ]['data' ]
309+ self .assertEqual (sent , json .loads (json_sent ))
303310
304311 def test_list_buckets_empty (self ):
305312 from six .moves .urllib .parse import parse_qs
@@ -422,7 +429,7 @@ def test_page_non_empty_response(self):
422429 credentials = _make_credentials ()
423430 client = self ._make_one (project = project , credentials = credentials )
424431
425- blob_name = 'blob -name'
432+ blob_name = 'bucket -name'
426433 response = {'items' : [{'name' : blob_name }]}
427434
428435 def dummy_response ():
0 commit comments