def _download_to_filename_helper(self, fake_session_factory, updated=None):
    import os
    import time
    from google.cloud._testing import _NamedTemporaryFile
    blob_name = 'blob-name'
    fake_session_factory.return_value = self._mock_download_transport()
    client = mock.Mock(_credentials=_make_credentials(), spec=['_credentials'])
    bucket = _Bucket(client)
    media_link = 'http://example.com/media/'
    properties = {'mediaLink': media_link}
    if (updated is not None):
        properties['updated'] = updated
    blob = self._make_one(blob_name, bucket=bucket, properties=properties)
    blob._CHUNK_SIZE_MULTIPLE = 1
    blob.chunk_size = 3
    with _NamedTemporaryFile() as temp:
        blob.download_to_filename(temp.name)
        with open(temp.name, 'rb') as file_obj:
            wrote = file_obj.read()
            if (updated is None):
                self.assertIsNone(blob.updated)
            else:
                mtime = os.path.getmtime(temp.name)
                updated_time = time.mktime(blob.updated.timetuple())
                self.assertEqual(mtime, updated_time)
    self.assertEqual(wrote, b'abcdef')
    self._check_session_mocks(client, fake_session_factory, media_link)
def _download_to_filename_helper(self, fake_session_factory, updated=None):
    import os
    import time
    from google.cloud._testing import _NamedTemporaryFile
    blob_name = 'blob-name'
    fake_session_factory.return_value = self._mock_download_transport()
    client = mock.Mock(_credentials=_make_credentials(), spec=['_credentials'])
    bucket = _Bucket(client)
    media_link = 'http://example.com/media/'
    properties = {'mediaLink': media_link}
    if (updated is not None):
        properties['updated'] = updated
    blob = self._make_one(blob_name, bucket=bucket, properties=properties)
    blob._CHUNK_SIZE_MULTIPLE = 1
    blob.chunk_size = 3
    with _NamedTemporaryFile() as temp:
        blob.download_to_filename(temp.name)
        with open(temp.name, 'rb') as file_obj:
            wrote = file_obj.read()
            if (updated is None):
                self.assertIsNone(blob.updated)
            else:
                mtime = os.path.getmtime(temp.name)
                updated_time = time.mktime(blob.updated.timetuple())
                self.assertEqual(mtime, updated_time)
    self.assertEqual(wrote, b'abcdef')
    self._check_session_mocks(client, fake_session_factory, media_link)