File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ def _query_params(self):
136136 def reload (
137137 self ,
138138 client = None ,
139+ projection = "noAcl" ,
139140 timeout = _DEFAULT_TIMEOUT ,
140141 if_generation_match = None ,
141142 if_generation_not_match = None ,
@@ -151,6 +152,11 @@ def reload(
151152 :param client: the client to use. If not passed, falls back to the
152153 ``client`` stored on the current object.
153154
155+ :type projection: str
156+ :param projection: (Optional) If used, must be 'full' or 'noAcl'.
157+ Defaults to ``'noAcl'``. Specifies the set of
158+ properties to return.
159+
154160 :type timeout: float or tuple
155161 :param timeout: (Optional) The amount of time, in seconds, to wait
156162 for the server response.
@@ -183,7 +189,7 @@ def reload(
183189 query_params = self ._query_params
184190 # Pass only '?projection=noAcl' here because 'acl' and related
185191 # are handled via custom endpoints.
186- query_params ["projection" ] = "noAcl"
192+ query_params ["projection" ] = projection
187193 _add_generation_match_parameters (
188194 query_params ,
189195 if_generation_match = if_generation_match ,
Original file line number Diff line number Diff line change @@ -888,6 +888,18 @@ def test_resumable_upload_with_generation_match(self):
888888 with open (file_data ["path" ], "rb" ) as file_obj :
889889 blob .upload_from_file (file_obj , if_metageneration_match = 3 )
890890
891+ def test_upload_blob_owner (self ):
892+ blob = self .bucket .blob ("MyBuffer" )
893+ file_contents = b"Hello World"
894+ blob .upload_from_string (file_contents )
895+ self .case_blobs_to_delete .append (blob )
896+
897+ same_blob = self .bucket .blob ("MyBuffer" )
898+ same_blob .reload (projection = "full" ) # Initialize properties.
899+ user_email = Config .CLIENT ._credentials .service_account_email
900+ owner = same_blob .owner
901+ self .assertIn (user_email , owner ["entity" ])
902+
891903
892904class TestUnicode (unittest .TestCase ):
893905 @vpcsc_config .skip_if_inside_vpcsc
Original file line number Diff line number Diff line change @@ -187,6 +187,30 @@ def test_reload_w_user_project(self):
187187 )
188188 self .assertEqual (derived ._changes , set ())
189189
190+ def test_reload_w_projection (self ):
191+ connection = _Connection ({"foo" : "Foo" })
192+ client = _Client (connection )
193+ derived = self ._derivedClass ("/path" )()
194+ # Make sure changes is not a set instance before calling reload
195+ # (which will clear / replace it with an empty set), checked below.
196+ derived ._changes = object ()
197+ derived .reload (projection = "full" , client = client , timeout = 42 )
198+ self .assertEqual (derived ._properties , {"foo" : "Foo" })
199+ kw = connection ._requested
200+ self .assertEqual (len (kw ), 1 )
201+ self .assertEqual (
202+ kw [0 ],
203+ {
204+ "method" : "GET" ,
205+ "path" : "/path" ,
206+ "query_params" : {"projection" : "full" },
207+ "headers" : {},
208+ "_target_object" : derived ,
209+ "timeout" : 42 ,
210+ },
211+ )
212+ self .assertEqual (derived ._changes , set ())
213+
190214 def test__set_properties (self ):
191215 mixin = self ._make_one ()
192216 self .assertEqual (mixin ._properties , {})
You can’t perform that action at this time.
0 commit comments