def test_storage_celery_save(self):
        storage = QueuedStorage(
            local='django.core.files.storage.FileSystemStorage',
            remote='django.core.files.storage.FileSystemStorage',
            local_options=dict(location=self.local_dir),
            remote_options=dict(location=self.remote_dir))

        field = models.TestModel._meta.get_field('testfile')
        field.storage = storage

        obj = models.TestModel(testfile=File(self.test_file))
        obj.save()

        self.assertTrue(obj.testfile.storage.result.get())
        self.assertTrue(path.isfile(path.join(self.local_dir, obj.testfile.name)))
        self.assertTrue(
            path.isfile(path.join(self.remote_dir, obj.testfile.name)),
            "Remote file is not available.")
        self.assertFalse(storage.using_local(obj.testfile.name))
        self.assertTrue(storage.using_remote(obj.testfile.name))

        self.assertEqual(self.test_file_name,
                         storage.get_valid_name(self.test_file_name))
        self.assertEqual(self.test_file_name,
                         storage.get_available_name(self.test_file_name))

        subdir_path = os.path.join('test', self.test_file_name)
        self.assertTrue(storage.exists(subdir_path))
        self.assertEqual(storage.path(self.test_file_name),
                         path.join(self.local_dir, self.test_file_name))
        self.assertEqual(storage.listdir('test')[1], [self.test_file_name])
        self.assertEqual(storage.size(subdir_path),
                         os.stat(self.test_file_path).st_size)
        self.assertEqual(storage.url(self.test_file_name), self.test_file_name)
        self.assertIsInstance(storage.accessed_time(subdir_path), datetime)
        self.assertIsInstance(storage.created_time(subdir_path), datetime)
        self.assertIsInstance(storage.modified_time(subdir_path), datetime)

        subdir_name = 'queued_storage_2.txt'
        testfile = storage.open(subdir_name, 'w')
        try:
            testfile.write('test')
        finally:
            testfile.close()
        self.assertTrue(storage.exists(subdir_name))
        storage.delete(subdir_name)
        self.assertFalse(storage.exists(subdir_name))
Move a file or directory
dataset/ETHPy150Open jazzband/django-queued-storage/tests/test_storages.py/StorageTests.test_storage_celery_save--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/move