Files
ThousandHands/tests/core/objects/test_backup_object.py
2024-12-08 16:53:09 +08:00

33 lines
1.0 KiB
Python

from ThousandHands.core.objects.backup_object import BackupObject
import tempfile
import os
class TestBackup():
def createTempDataDir(self):
temp_data_dir = tempfile.TemporaryDirectory()
for i in range(100):
f = open(temp_data_dir.name + "/testFile" + str(i), "w")
f.write("test data"+str(i))
f.close()
os.mkdir(temp_data_dir.name + "/testDir")
for i in range(100):
f = open(temp_data_dir.name + "/testDir/testFile" + str(i), "w")
f.write("test data1"*10000+str(i))
f.close()
return temp_data_dir
def test_BackupWriteBlob(self):
'''
测试备份写入blob
'''
with tempfile.TemporaryDirectory() as tmpdir:
temp_data_dir = self.createTempDataDir()
b = BackupObject("testBackup", tmpdir)
b.addBackup([temp_data_dir.name])
b.backup()
temp_data_dir.cleanup()
assert os.path.exists(b.backup_path+"/objects")