Esempio n. 1
0
    def test_posix_destination_already_exists(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / '1'
            source.makedirs_p()

            with self.assertRaisesRegexp(OSError, 'exists'):
                utils.copytree(source, tmp_d)
Esempio n. 2
0
    def test_posix_destination_w_error(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            invalid_source = tmp_d / 'source'
            dest = tmp_d / 'my' / 'dest'

            with self.assertRaises(OSError):
                utils.copytree(invalid_source, dest)
Esempio n. 3
0
    def test_posix_destination_w_cmd(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / 'source'
            os.mkdir(source)
            with open(source / '1', 'w') as tmp_file:
                tmp_file.write('1')

            dest = tmp_d / 'my' / 'dest'
            utils.copytree(source, dest, copy_cmd='cp -r')
            self.assertTrue((dest / '1').exists())
Esempio n. 4
0
    def test_swift_destination(self, mock_upload):
        source = '.'
        dest = Path('swift://tenant/container')
        options = {
            'swift:upload': {
                'object_threads': 30,
                'segment_threads': 40
            }
        }

        with settings.use(options):
            utils.copytree(source, dest)
        mock_upload.assert_called_once_with(dest, ['.'],
                                            condition=None,
                                            use_manifest=False,
                                            headers=None)