@@ -562,6 +562,54 @@ def test_get_bucket_with_object_hit(self):
562562 parms = dict (urlparse .parse_qsl (qs ))
563563 self .assertEqual (parms ["projection" ], "noAcl" )
564564
565+ def test_get_bucket_default_retry (self ):
566+ from google .cloud .storage .bucket import Bucket
567+ from google .cloud .storage ._http import Connection
568+
569+ PROJECT = "PROJECT"
570+ CREDENTIALS = _make_credentials ()
571+ client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
572+
573+ bucket_name = "bucket-name"
574+ bucket_obj = Bucket (client , bucket_name )
575+
576+ with mock .patch .object (Connection , "api_request" ) as req :
577+ client .get_bucket (bucket_obj )
578+
579+ req .assert_called_once_with (
580+ method = "GET" ,
581+ path = mock .ANY ,
582+ query_params = mock .ANY ,
583+ headers = mock .ANY ,
584+ _target_object = bucket_obj ,
585+ timeout = mock .ANY ,
586+ retry = DEFAULT_RETRY ,
587+ )
588+
589+ def test_get_bucket_respects_retry_override (self ):
590+ from google .cloud .storage .bucket import Bucket
591+ from google .cloud .storage ._http import Connection
592+
593+ PROJECT = "PROJECT"
594+ CREDENTIALS = _make_credentials ()
595+ client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
596+
597+ bucket_name = "bucket-name"
598+ bucket_obj = Bucket (client , bucket_name )
599+
600+ with mock .patch .object (Connection , "api_request" ) as req :
601+ client .get_bucket (bucket_obj , retry = None )
602+
603+ req .assert_called_once_with (
604+ method = "GET" ,
605+ path = mock .ANY ,
606+ query_params = mock .ANY ,
607+ headers = mock .ANY ,
608+ _target_object = bucket_obj ,
609+ timeout = mock .ANY ,
610+ retry = None ,
611+ )
612+
565613 def test_lookup_bucket_miss (self ):
566614 PROJECT = "PROJECT"
567615 CREDENTIALS = _make_credentials ()
@@ -658,6 +706,29 @@ def test_lookup_bucket_with_metageneration_match(self):
658706 self .assertEqual (parms ["projection" ], "noAcl" )
659707 self .assertEqual (parms ["ifMetagenerationMatch" ], str (METAGENERATION_NUMBER ))
660708
709+ def test_lookup_bucket_default_retry (self ):
710+ from google .cloud .storage .bucket import Bucket
711+ from google .cloud .storage ._http import Connection
712+
713+ PROJECT = "PROJECT"
714+ CREDENTIALS = _make_credentials ()
715+ client = self ._make_one (project = PROJECT , credentials = CREDENTIALS )
716+
717+ bucket_name = "bucket-name"
718+ bucket_obj = Bucket (client , bucket_name )
719+
720+ with mock .patch .object (Connection , "api_request" ) as req :
721+ client .lookup_bucket (bucket_obj )
722+ req .assert_called_once_with (
723+ method = "GET" ,
724+ path = mock .ANY ,
725+ query_params = mock .ANY ,
726+ headers = mock .ANY ,
727+ _target_object = bucket_obj ,
728+ timeout = mock .ANY ,
729+ retry = DEFAULT_RETRY ,
730+ )
731+
661732 def test_create_bucket_w_missing_client_project (self ):
662733 credentials = _make_credentials ()
663734 client = self ._make_one (project = None , credentials = credentials )
0 commit comments