@mock.patch('google.auth.transport.requests.AuthorizedSession')
def test_download_to_file_wo_media_link(self, fake_session_factory):
    blob_name = 'blob-name'
    fake_session_factory.return_value = self._mock_download_transport()
    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
    file_obj = io.BytesIO()
    blob.download_to_file(file_obj)
    self.assertEqual(file_obj.getvalue(), b'abcdef')
    self.assertIsNone(blob.media_link)
    expected_url = 'https://www.googleapis.com/download/storage/v1/b/name/o/blob-name?alt=media'
    self._check_session_mocks(client, fake_session_factory, expected_url)
@mock.patch('google.auth.transport.requests.AuthorizedSession')
def test_download_to_file_wo_media_link(self, fake_session_factory):
    blob_name = 'blob-name'
    fake_session_factory.return_value = self._mock_download_transport()
    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
    file_obj = io.BytesIO()
    blob.download_to_file(file_obj)
    self.assertEqual(file_obj.getvalue(), b'abcdef')
    self.assertIsNone(blob.media_link)
    expected_url = 'https://www.googleapis.com/download/storage/v1/b/name/o/blob-name?alt=media'
    self._check_session_mocks(client, fake_session_factory, expected_url)