Пример #1
0
 def test_create_transfer_manager(self):
     client = object()
     config = TransferConfig()
     osutil = OSUtils()
     with mock.patch('boto3.s3.transfer.TransferManager') as manager:
         create_transfer_manager(client, config, osutil)
         assert manager.call_args == mock.call(client, config, osutil, None)
Пример #2
0
 def test_open_file_chunk_reader(self):
     with mock.patch('boto3.s3.transfer.ReadFileChunk') as m:
         OSUtils().open_file_chunk_reader('myfile', 0, 100, None)
         m.from_filename.assert_called_with('myfile',
                                            0,
                                            100,
                                            None,
                                            enable_callback=False)
Пример #3
0
 def test_get_file_size(self):
     with mock.patch('os.path.getsize') as m:
         OSUtils().get_file_size('myfile')
         m.assert_called_with('myfile')
Пример #4
0
 def test_rename_file(self):
     with mock.patch('boto3.compat.rename_file') as rename_file:
         OSUtils().rename_file('foo', 'newfoo')
         rename_file.assert_called_with('foo', 'newfoo')
Пример #5
0
 def test_remove_file_proxies_remove_file(self):
     with mock.patch('os.remove') as remove:
         OSUtils().remove_file('foo')
         remove.assert_called_with('foo')
Пример #6
0
 def test_remove_file_ignores_errors(self):
     with mock.patch('os.remove') as remove:
         remove.side_effect = OSError('fake error')
         OSUtils().remove_file('foo')
     remove.assert_called_with('foo')
Пример #7
0
 def test_open_file(self):
     fileobj = OSUtils().open(os.path.join(self.tempdir, 'foo'), 'w')
     self.assertTrue(hasattr(fileobj, 'write'))
Пример #8
0
 def test_can_create_with_extra_configurations(self):
     transfer = S3Transfer(client=mock.Mock(),
                           config=TransferConfig(),
                           osutil=OSUtils())
     self.assertIsInstance(transfer, S3Transfer)