@@ -291,6 +291,32 @@ def test_delete(self):
291
291
self .assertFalse (blob .exists ())
292
292
self .assertEqual (bucket ._deleted , [(BLOB_NAME , None )])
293
293
294
+ def test_download_to_file_wo_media_link (self ):
295
+ from six .moves .http_client import OK
296
+ from six .moves .http_client import PARTIAL_CONTENT
297
+ from io import BytesIO
298
+ BLOB_NAME = 'blob-name'
299
+ MEDIA_LINK = 'http://example.com/media/'
300
+ chunk1_response = {'status' : PARTIAL_CONTENT ,
301
+ 'content-range' : 'bytes 0-2/6' }
302
+ chunk2_response = {'status' : OK ,
303
+ 'content-range' : 'bytes 3-5/6' }
304
+ connection = _Connection (
305
+ (chunk1_response , b'abc' ),
306
+ (chunk2_response , b'def' ),
307
+ )
308
+ # Only the 'reload' request hits on this side: the others are done
309
+ # through the 'http' object.
310
+ reload_response = {'status' : OK , 'content-type' : 'application/json' }
311
+ connection ._responses = [(reload_response , {"mediaLink" : MEDIA_LINK })]
312
+ client = _Client (connection )
313
+ bucket = _Bucket (client )
314
+ blob = self ._makeOne (BLOB_NAME , bucket = bucket )
315
+ fh = BytesIO ()
316
+ blob .download_to_file (fh )
317
+ self .assertEqual (fh .getvalue (), b'abcdef' )
318
+ self .assertEqual (blob .media_link , MEDIA_LINK )
319
+
294
320
def _download_to_file_helper (self , chunk_size = None ):
295
321
from six .moves .http_client import OK
296
322
from six .moves .http_client import PARTIAL_CONTENT
0 commit comments