@@ -67,10 +67,11 @@ def _make_client(self, project=BUCKET_PROJECT):
67
67
68
68
return mock .Mock (project = project , spec = Client )
69
69
70
- def _make_bucket (self , client , name = BUCKET_NAME ):
71
- bucket = mock .Mock (spec = ['client' , 'name' ])
70
+ def _make_bucket (self , client , name = BUCKET_NAME , user_project = None ):
71
+ bucket = mock .Mock (spec = ['client' , 'name' , 'user_project' ])
72
72
bucket .client = client
73
73
bucket .name = name
74
+ bucket .user_project = user_project
74
75
return bucket
75
76
76
77
def test_ctor_defaults (self ):
@@ -268,13 +269,15 @@ def test_create_w_defaults(self):
268
269
api_request .assert_called_once_with (
269
270
method = 'POST' ,
270
271
path = self .CREATE_PATH ,
272
+ query_params = {},
271
273
data = data ,
272
274
)
273
275
274
276
def test_create_w_explicit_client (self ):
277
+ USER_PROJECT = 'user-project-123'
275
278
client = self ._make_client ()
276
279
alt_client = self ._make_client ()
277
- bucket = self ._make_bucket (client )
280
+ bucket = self ._make_bucket (client , user_project = USER_PROJECT )
278
281
notification = self ._make_one (
279
282
bucket , self .TOPIC_NAME ,
280
283
topic_project = self .TOPIC_ALT_PROJECT ,
@@ -317,6 +320,7 @@ def test_create_w_explicit_client(self):
317
320
api_request .assert_called_once_with (
318
321
method = 'POST' ,
319
322
path = self .CREATE_PATH ,
323
+ query_params = {'userProject' : USER_PROJECT },
320
324
data = data ,
321
325
)
322
326
@@ -344,11 +348,13 @@ def test_exists_miss(self):
344
348
api_request .assert_called_once_with (
345
349
method = 'GET' ,
346
350
path = self .NOTIFICATION_PATH ,
351
+ query_params = {},
347
352
)
348
353
349
354
def test_exists_hit (self ):
355
+ USER_PROJECT = 'user-project-123'
350
356
client = self ._make_client ()
351
- bucket = self ._make_bucket (client )
357
+ bucket = self ._make_bucket (client , user_project = USER_PROJECT )
352
358
alt_client = self ._make_client ()
353
359
notification = self ._make_one (bucket , self .TOPIC_NAME )
354
360
notification ._properties ['id' ] = self .NOTIFICATION_ID
@@ -365,6 +371,7 @@ def test_exists_hit(self):
365
371
api_request .assert_called_once_with (
366
372
method = 'GET' ,
367
373
path = self .NOTIFICATION_PATH ,
374
+ query_params = {'userProject' : USER_PROJECT },
368
375
)
369
376
370
377
def test_reload_wo_notification_id (self ):
@@ -392,13 +399,15 @@ def test_reload_miss(self):
392
399
api_request .assert_called_once_with (
393
400
method = 'GET' ,
394
401
path = self .NOTIFICATION_PATH ,
402
+ query_params = {},
395
403
)
396
404
397
405
def test_reload_hit (self ):
398
406
from google .cloud .storage .notification import NONE_PAYLOAD_FORMAT
399
407
408
+ USER_PROJECT = 'user-project-123'
400
409
client = self ._make_client ()
401
- bucket = self ._make_bucket (client )
410
+ bucket = self ._make_bucket (client , user_project = USER_PROJECT )
402
411
alt_client = self ._make_client ()
403
412
notification = self ._make_one (bucket , self .TOPIC_NAME )
404
413
notification ._properties ['id' ] = self .NOTIFICATION_ID
@@ -423,6 +432,7 @@ def test_reload_hit(self):
423
432
api_request .assert_called_once_with (
424
433
method = 'GET' ,
425
434
path = self .NOTIFICATION_PATH ,
435
+ query_params = {'userProject' : USER_PROJECT },
426
436
)
427
437
428
438
def test_delete_wo_notification_id (self ):
@@ -450,11 +460,13 @@ def test_delete_miss(self):
450
460
api_request .assert_called_once_with (
451
461
method = 'DELETE' ,
452
462
path = self .NOTIFICATION_PATH ,
463
+ query_params = {},
453
464
)
454
465
455
466
def test_delete_hit (self ):
467
+ USER_PROJECT = 'user-project-123'
456
468
client = self ._make_client ()
457
- bucket = self ._make_bucket (client )
469
+ bucket = self ._make_bucket (client , user_project = USER_PROJECT )
458
470
alt_client = self ._make_client ()
459
471
notification = self ._make_one (bucket , self .TOPIC_NAME )
460
472
notification ._properties ['id' ] = self .NOTIFICATION_ID
@@ -466,4 +478,5 @@ def test_delete_hit(self):
466
478
api_request .assert_called_once_with (
467
479
method = 'DELETE' ,
468
480
path = self .NOTIFICATION_PATH ,
481
+ query_params = {'userProject' : USER_PROJECT },
469
482
)
0 commit comments