def test_can_provide_file_size(self): self.add_successful_copy_responses() call_kwargs = self.create_call_kwargs() call_kwargs['subscribers'] = [FileSizeProvider(len(self.content))] future = self.manager.copy(**call_kwargs) future.result() # The HeadObject should have not happened and should have been able # to successfully copy the file. self.stubber.assert_no_pending_responses()
def test_can_provide_file_size(self): self.add_successful_get_object_responses() call_kwargs = self.create_call_kwargs() call_kwargs['subscribers'] = [FileSizeProvider(len(self.content))] future = self.manager.download(**call_kwargs) future.result() # The HeadObject should have not happened and should have been able # to successfully download the file. self.stubber.assert_no_pending_responses() with open(self.filename, 'rb') as f: self.assertEqual(self.content, f.read())
def test_provide_file_size_on_put(self): self.call_args.subscribers.append(FileSizeProvider(len(self.content))) self.stubber.add_response(method='put_object', service_response={}, expected_params={ 'Body': ANY, 'Bucket': self.bucket, 'Key': self.key }) # With this submitter, it will fail to stat the file if a transfer # size is not provided. self.submission_main_kwargs['osutil'] = OSUtilsExceptionOnFileSize() self.submission_task = self.get_task( UploadSubmissionTask, main_kwargs=self.submission_main_kwargs) self.submission_task() self.transfer_future.result() self.stubber.assert_no_pending_responses() self.assertEqual(self.sent_bodies, [self.content])