def test_dump_load_data(self):
        # Initialize the test data
        create_folder_structure(1,1)
        fileobj = self.create_filer_file(Folder.objects.all()[0])
        jdata = StringIO()

        # Dump the current data
        fobj = tempfile.NamedTemporaryFile(suffix=".json", delete=False)
        call_command("dumpdata", "filer", stdout=jdata, indent=3)

        # Delete database and filesystem data
        complete = os.path.join(fileobj.file.storage.location, fileobj.path)
        os.unlink(complete)
        fileobj.delete()

        # Dump data to json file
        fobj.write(jdata.getvalue().encode('utf-8'))
        fobj.seek(0)

        # Load data back
        call_command("loaddata", fobj.name, stdout=jdata)

        # Database data is restored
        self.assertEqual(Folder.objects.all().count(), 1)
        self.assertEqual(File.objects.all().count(), 1)
        self.assertEqual(File.objects.all()[0].original_filename, self.image_name)

        fileobj = File.objects.all()[0]
        complete = os.path.join(fileobj.file.storage.location, fileobj.path)
        # Filesystem data is not
        self.assertFalse(os.path.exists(complete))
Testing the dump / load with no dump of file content data
dataset/ETHPy150Open divio/django-filer/filer/tests/dump.py/DumpDataTests.test_dump_load_data