@@ -387,52 +387,58 @@ def test_exists_hit_w_explicit_w_user_project(self):
387387 )
388388
389389 def test_reload_wo_notification_id (self ):
390- client = self ._make_client ()
390+ client = mock .Mock (spec = ["_get_path" , "project" ])
391+ client .project = self .BUCKET_PROJECT
391392 bucket = self ._make_bucket (client )
392393 notification = self ._make_one (bucket , self .TOPIC_NAME )
393394
394395 with self .assertRaises (ValueError ):
395396 notification .reload ()
396397
397- def test_reload_miss (self ):
398+ client ._get_path .assert_not_called ()
399+
400+ def test_reload_miss_w_defaults (self ):
398401 from google .cloud .exceptions import NotFound
399402
400- client = self ._make_client ()
403+ client = mock .Mock (spec = ["_get_path" , "project" ])
404+ client ._get_path .side_effect = NotFound ("testing" )
405+ client .project = self .BUCKET_PROJECT
401406 bucket = self ._make_bucket (client )
402407 notification = self ._make_one (bucket , self .TOPIC_NAME )
403408 notification ._properties ["id" ] = self .NOTIFICATION_ID
404- api_request = client ._connection .api_request
405- api_request .side_effect = NotFound ("testing" )
406409
407410 with self .assertRaises (NotFound ):
408- notification .reload (timeout = 42 )
411+ notification .reload ()
409412
410- api_request . assert_called_once_with (
411- method = "GET" ,
412- path = self .NOTIFICATION_PATH ,
413- query_params = {} ,
414- timeout = 42 ,
413+ expected_query_params = {}
414+ client . _get_path . assert_called_once_with (
415+ self .NOTIFICATION_PATH ,
416+ query_params = expected_query_params ,
417+ timeout = self . _get_default_timeout () ,
415418 retry = DEFAULT_RETRY ,
416419 )
417420
418- def test_reload_hit (self ):
421+ def test_reload_hit_w_explicit_w_user_project (self ):
419422 from google .cloud .storage .notification import NONE_PAYLOAD_FORMAT
420423
421- USER_PROJECT = "user-project-123"
422- client = self ._make_client ()
423- bucket = self ._make_bucket (client , user_project = USER_PROJECT )
424- notification = self ._make_one (bucket , self .TOPIC_NAME )
425- notification ._properties ["id" ] = self .NOTIFICATION_ID
426- api_request = client ._connection .api_request
427- api_request .return_value = {
424+ user_project = "user-project-123"
425+ api_response = {
428426 "topic" : self .TOPIC_REF ,
429427 "id" : self .NOTIFICATION_ID ,
430428 "etag" : self .ETAG ,
431429 "selfLink" : self .SELF_LINK ,
432430 "payload_format" : NONE_PAYLOAD_FORMAT ,
433431 }
432+ client = mock .Mock (spec = ["_get_path" , "project" ])
433+ client ._get_path .return_value = api_response
434+ client .project = self .BUCKET_PROJECT
435+ bucket = self ._make_bucket (client , user_project = user_project )
436+ notification = self ._make_one (bucket , self .TOPIC_NAME )
437+ notification ._properties ["id" ] = self .NOTIFICATION_ID
438+ timeout = 42
439+ retry = mock .Mock (spec = [])
434440
435- notification .reload (client = client )
441+ notification .reload (client = client , timeout = timeout , retry = retry )
436442
437443 self .assertEqual (notification .etag , self .ETAG )
438444 self .assertEqual (notification .self_link , self .SELF_LINK )
@@ -441,12 +447,12 @@ def test_reload_hit(self):
441447 self .assertIsNone (notification .blob_name_prefix )
442448 self .assertEqual (notification .payload_format , NONE_PAYLOAD_FORMAT )
443449
444- api_request . assert_called_once_with (
445- method = "GET" ,
446- path = self .NOTIFICATION_PATH ,
447- query_params = { "userProject" : USER_PROJECT } ,
448- timeout = self . _get_default_timeout () ,
449- retry = DEFAULT_RETRY ,
450+ expected_query_params = { "userProject" : user_project }
451+ client . _get_path . assert_called_once_with (
452+ self .NOTIFICATION_PATH ,
453+ query_params = expected_query_params ,
454+ timeout = timeout ,
455+ retry = retry ,
450456 )
451457
452458 def test_delete_wo_notification_id (self ):
0 commit comments