def test__do_download_chunked(self):
    blob_name = 'blob-name'
    client = mock.Mock(_credentials=_make_credentials(), spec=['_credentials'])
    bucket = _Bucket(client)
    blob = self._make_one(blob_name, bucket=bucket)
    blob._CHUNK_SIZE_MULTIPLE = 1
    blob.chunk_size = 3
    transport = self._mock_download_transport()
    file_obj = io.BytesIO()
    download_url = 'http://test.invalid'
    headers = {}
    blob._do_download(transport, file_obj, download_url, headers)
    self.assertEqual(file_obj.getvalue(), b'abcdef')
    self.assertEqual(transport.request.call_count, 2)
    self.assertEqual(headers, {'range': 'bytes=3-5'})
    call = mock.call('GET', download_url, data=None, headers=headers)
    self.assertEqual(transport.request.mock_calls, [call, call])
def test__do_download_chunked(self):
    blob_name = 'blob-name'
    client = mock.Mock(_credentials=_make_credentials(), spec=['_credentials'])
    bucket = _Bucket(client)
    blob = self._make_one(blob_name, bucket=bucket)
    blob._CHUNK_SIZE_MULTIPLE = 1
    blob.chunk_size = 3
    transport = self._mock_download_transport()
    file_obj = io.BytesIO()
    download_url = 'http://test.invalid'
    headers = {}
    blob._do_download(transport, file_obj, download_url, headers)
    self.assertEqual(file_obj.getvalue(), b'abcdef')
    self.assertEqual(transport.request.call_count, 2)
    self.assertEqual(headers, {'range': 'bytes=3-5'})
    call = mock.call('GET', download_url, data=None, headers=headers)
    self.assertEqual(transport.request.mock_calls, [call, call])