@@ -155,22 +155,22 @@ def test_get_bucket_hit(self):
155155 CREDENTIALS = _make_credentials ()
156156 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
157157
158- BLOB_NAME = 'blob -name'
158+ BUCKET_NAME = 'bucket -name'
159159 URI = '/' .join ([
160160 client ._connection .API_BASE_URL ,
161161 'storage' ,
162162 client ._connection .API_VERSION ,
163163 'b' ,
164- '%s?projection=noAcl' % (BLOB_NAME ,),
164+ '%s?projection=noAcl' % (BUCKET_NAME ,),
165165 ])
166166 http = client ._http_internal = _Http (
167167 {'status' : '200' , 'content-type' : 'application/json' },
168- '{{"name": "{0}"}}' .format (BLOB_NAME ).encode ('utf-8' ),
168+ '{{"name": "{0}"}}' .format (BUCKET_NAME ).encode ('utf-8' ),
169169 )
170170
171- bucket = client .get_bucket (BLOB_NAME )
171+ bucket = client .get_bucket (BUCKET_NAME )
172172 self .assertIsInstance (bucket , Bucket )
173- self .assertEqual (bucket .name , BLOB_NAME )
173+ self .assertEqual (bucket .name , BUCKET_NAME )
174174 self .assertEqual (http ._called_with ['method' ], 'GET' )
175175 self .assertEqual (http ._called_with ['uri' ], URI )
176176
@@ -203,33 +203,34 @@ def test_lookup_bucket_hit(self):
203203 CREDENTIALS = _make_credentials ()
204204 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
205205
206- BLOB_NAME = 'blob -name'
206+ BUCKET_NAME = 'bucket -name'
207207 URI = '/' .join ([
208208 client ._connection .API_BASE_URL ,
209209 'storage' ,
210210 client ._connection .API_VERSION ,
211211 'b' ,
212- '%s?projection=noAcl' % (BLOB_NAME ,),
212+ '%s?projection=noAcl' % (BUCKET_NAME ,),
213213 ])
214214 http = client ._http_internal = _Http (
215215 {'status' : '200' , 'content-type' : 'application/json' },
216- '{{"name": "{0}"}}' .format (BLOB_NAME ).encode ('utf-8' ),
216+ '{{"name": "{0}"}}' .format (BUCKET_NAME ).encode ('utf-8' ),
217217 )
218218
219- bucket = client .lookup_bucket (BLOB_NAME )
219+ bucket = client .lookup_bucket (BUCKET_NAME )
220220 self .assertIsInstance (bucket , Bucket )
221- self .assertEqual (bucket .name , BLOB_NAME )
221+ self .assertEqual (bucket .name , BUCKET_NAME )
222222 self .assertEqual (http ._called_with ['method' ], 'GET' )
223223 self .assertEqual (http ._called_with ['uri' ], URI )
224224
225225 def test_create_bucket_conflict (self ):
226+ import json
226227 from google .cloud .exceptions import Conflict
227228
228229 PROJECT = 'PROJECT'
229230 CREDENTIALS = _make_credentials ()
230231 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
231232
232- BLOB_NAME = 'blob -name'
233+ BUCKET_NAME = 'bucket -name'
233234 URI = '/' .join ([
234235 client ._connection .API_BASE_URL ,
235236 'storage' ,
@@ -241,18 +242,21 @@ def test_create_bucket_conflict(self):
241242 '{"error": {"message": "Conflict"}}' ,
242243 )
243244
244- self .assertRaises (Conflict , client .create_bucket , BLOB_NAME )
245+ self .assertRaises (Conflict , client .create_bucket , BUCKET_NAME )
245246 self .assertEqual (http ._called_with ['method' ], 'POST' )
246247 self .assertEqual (http ._called_with ['uri' ], URI )
248+ body = json .loads (http ._called_with ['body' ])
249+ self .assertEqual (body , {'name' : BUCKET_NAME })
247250
248251 def test_create_bucket_success (self ):
252+ import json
249253 from google .cloud .storage .bucket import Bucket
250254
251255 PROJECT = 'PROJECT'
252256 CREDENTIALS = _make_credentials ()
253257 client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
254258
255- BLOB_NAME = 'blob -name'
259+ BUCKET_NAME = 'bucket -name'
256260 URI = '/' .join ([
257261 client ._connection .API_BASE_URL ,
258262 'storage' ,
@@ -261,14 +265,17 @@ def test_create_bucket_success(self):
261265 ])
262266 http = client ._http_internal = _Http (
263267 {'status' : '200' , 'content-type' : 'application/json' },
264- '{{"name": "{0}"}}' .format (BLOB_NAME ).encode ('utf-8' ),
268+ '{{"name": "{0}"}}' .format (BUCKET_NAME ).encode ('utf-8' ),
265269 )
266270
267- bucket = client .create_bucket (BLOB_NAME )
271+ bucket = client .create_bucket (BUCKET_NAME , requester_pays = True )
268272 self .assertIsInstance (bucket , Bucket )
269- self .assertEqual (bucket .name , BLOB_NAME )
273+ self .assertEqual (bucket .name , BUCKET_NAME )
270274 self .assertEqual (http ._called_with ['method' ], 'POST' )
271275 self .assertEqual (http ._called_with ['uri' ], URI )
276+ body = json .loads (http ._called_with ['body' ])
277+ self .assertEqual (
278+ body , {'name' : BUCKET_NAME , 'billing' : {'requesterPays' : True }})
272279
273280 def test_list_buckets_empty (self ):
274281 from six .moves .urllib .parse import parse_qs
@@ -400,7 +407,7 @@ def test_page_non_empty_response(self):
400407 credentials = _make_credentials ()
401408 client = self ._make_one (project = project , credentials = credentials )
402409
403- blob_name = 'blob -name'
410+ blob_name = 'bucket -name'
404411 response = {'items' : [{'name' : blob_name }]}
405412
406413 def dummy_response ():
0 commit comments