def test_download_for_nonseekable_filelike_obj(self): self.add_head_object_response() self.add_successful_get_object_responses() with open(self.filename, 'wb') as f: future = self.manager.download( self.bucket, self.key, NonSeekableWriter(f), self.extra_args) future.result() # Ensure that the contents are correct with open(self.filename, 'rb') as f: self.assertEqual(self.content, f.read())
def tests_submits_tag_for_get_object_nonseekable_fileobj(self): self.wrap_executor_in_recorder() self.add_head_object_response() self.add_get_responses() with open(self.filename, 'wb') as f: self.use_fileobj_in_call_args(NonSeekableWriter(f)) self.submission_task = self.get_download_submission_task() self.wait_and_assert_completed_successfully(self.submission_task) # Make sure no tag to limit that task specifically was not associated # to that task submission. self.assert_tag_for_get_object(IN_MEMORY_DOWNLOAD_TAG)
def test_above_threshold_for_nonseekable_fileobj(self): transfer_manager = self.create_transfer_manager(self.config) filename = self.files.create_file_with_size('foo.txt', filesize=20 * 1024 * 1024) self.upload_file(filename, '20mb.txt') download_path = os.path.join(self.files.rootdir, '20mb.txt') with open(download_path, 'wb') as f: future = transfer_manager.download(self.bucket_name, '20mb.txt', NonSeekableWriter(f)) future.result() assert_files_equal(filename, download_path)
def open_nonseekable(self, filename, mode): self.open_call_args.append((filename, mode)) return NonSeekableWriter(six.BytesIO(self.content))