def test_zip_mounting(self): fs = db.FileSystem() zip = fs.open("test_utils/test_archive.zip", lockable=True) self.assertTrue(zip) fs.mount_archive(db.open_zip_archive(zip)) s = fs.open('test.txt') self.assertEqual(s.read().decode('utf-8'), "asdasdasd")
def test_seek_tell(self): fs = db.FileSystem() file = fs.open("test_utils/test_archive.zip") self.assertTrue(file) self.assertEqual(file.tell(), 0) file.seek(0, 2) size = file.tell() self.assertEqual(file.size(), size) file.seek(-1, 2) self.assertEqual(file.tell(), size - 1) file.seek(-100, 1) self.assertEqual(file.tell(), size - 101) file.seek(2, 1) self.assertEqual(file.tell(), size - 101 + 2) file.seek(0) self.assertEqual(file.tell(), 0)
def test_does_not_exist(self): fs = db.FileSystem() file = fs.open("does_not_exist") self.assertTrue(file is None)
def test_rename(self): fs = db.FileSystem() self.assertFalse(fs.exists('README2.md')) fs.rename('README.md', 'README2.md') self.assertTrue(fs.exists('README2.md')) fs.rename('README2.md', 'README.md')
def test_file_exist(self): fs = db.FileSystem() self.assertTrue(fs.exists('README.md'))