@@ -785,6 +785,51 @@ def test__delete_resource_hit_w_explicit(self):
785785 _target_object = target ,
786786 )
787787
788+ def test__bucket_arg_to_bucket_w_bucket_w_client (self ):
789+ from google .cloud .storage .bucket import Bucket
790+
791+ project = "PROJECT"
792+ credentials = _make_credentials ()
793+ client = self ._make_one (project = project , credentials = credentials )
794+ other_client = mock .Mock (spec = [])
795+ bucket_name = "w_client"
796+
797+ bucket = Bucket (other_client , name = bucket_name )
798+
799+ found = client ._bucket_arg_to_bucket (bucket )
800+
801+ self .assertIs (found , bucket )
802+ self .assertIs (found .client , other_client )
803+
804+ def test__bucket_arg_to_bucket_w_bucket_wo_client (self ):
805+ from google .cloud .storage .bucket import Bucket
806+
807+ project = "PROJECT"
808+ credentials = _make_credentials ()
809+ client = self ._make_one (project = project , credentials = credentials )
810+ bucket_name = "wo_client"
811+
812+ bucket = Bucket (client = None , name = bucket_name )
813+
814+ found = client ._bucket_arg_to_bucket (bucket )
815+
816+ self .assertIs (found , bucket )
817+ self .assertIs (found .client , client )
818+
819+ def test__bucket_arg_to_bucket_w_bucket_name (self ):
820+ from google .cloud .storage .bucket import Bucket
821+
822+ project = "PROJECT"
823+ credentials = _make_credentials ()
824+ client = self ._make_one (project = project , credentials = credentials )
825+ bucket_name = "string-name"
826+
827+ found = client ._bucket_arg_to_bucket (bucket_name )
828+
829+ self .assertIsInstance (found , Bucket )
830+ self .assertEqual (found .name , bucket_name )
831+ self .assertIs (found .client , client )
832+
788833 def test_get_bucket_miss_w_string_w_defaults (self ):
789834 from google .cloud .exceptions import NotFound
790835 from google .cloud .storage .bucket import Bucket
0 commit comments