def testFilePath(self): """ Test that all files report a FUSE path, and that this results in the same file as the non-fuse path. """ from girder.plugins import fuse as girder_fuse files = list(File().find()) for file in files: adapter = File().getAssetstoreAdapter(file) filesystempath = adapter.fullPath(file) filepath = girder_fuse.getFilePath(file) fusepath = girder_fuse.getFuseFilePath(file) self.assertTrue(os.path.exists(filesystempath)) self.assertTrue(os.path.exists(filepath)) self.assertTrue(os.path.exists(fusepath)) self.assertEqual(filesystempath, filepath) self.assertNotEqual(filesystempath, fusepath) self.assertEqual(fusepath[:len(self.mainMountPath)], self.mainMountPath) with open(filepath) as file1: with open(fusepath) as file2: self.assertEqual(file1.read(), file2.read()) subpath = fusepath[len(self.mainMountPath):].lstrip('/') if self.knownPaths.get(subpath): with open(fusepath) as file1: self.assertEqual(file1.read().strip(), self.knownPaths[subpath])
def testGetServerFusePath(self): from girder.plugins import fuse as girder_fuse from girder.plugins.fuse import MAIN_FUSE_KEY, server_fuse file = File().findOne() fusepath = girder_fuse.getFuseFilePath(file) sfpath = server_fuse.getServerFusePath(MAIN_FUSE_KEY, 'file', file) self.assertEqual(fusepath, sfpath) self.assertIsNone(server_fuse.getServerFusePath('unknown', 'file', file))
def testGetServerFusePath(self): from girder.plugins import fuse as girder_fuse from girder.plugins.fuse import MAIN_FUSE_KEY, server_fuse file = File().findOne() fusepath = girder_fuse.getFuseFilePath(file) sfpath = server_fuse.getServerFusePath(MAIN_FUSE_KEY, 'file', file) self.assertEqual(fusepath, sfpath) self.assertIsNone( server_fuse.getServerFusePath('unknown', 'file', file))
def testFilePathNoFullPath(self): """ Test that if an assetstore adapter doesn't respond to fullPath, we always get the fuse path. """ from girder.plugins import fuse as girder_fuse from girder.utility.filesystem_assetstore_adapter import FilesystemAssetstoreAdapter file = File().findOne() origFullPath = FilesystemAssetstoreAdapter.fullPath FilesystemAssetstoreAdapter.fullPath = None filepath = girder_fuse.getFilePath(file) fusepath = girder_fuse.getFuseFilePath(file) FilesystemAssetstoreAdapter.fullPath = origFullPath self.assertTrue(os.path.exists(filepath)) self.assertTrue(os.path.exists(fusepath)) self.assertEqual(filepath, fusepath)
def testFilePathNoLocalPath(self): """ Test that if an assetstore adapter doesn't respond to getLocalFilePath, we always get the fuse path. """ from girder.plugins import fuse as girder_fuse from girder.utility.filesystem_assetstore_adapter import FilesystemAssetstoreAdapter def getLocalFilePath(self, file): return super(FilesystemAssetstoreAdapter, self).getLocalFilePath(file) file = File().findOne() origGetLocalFilePath = FilesystemAssetstoreAdapter.getLocalFilePath FilesystemAssetstoreAdapter.getLocalFilePath = getLocalFilePath filepath = girder_fuse.getFilePath(file) fusepath = girder_fuse.getFuseFilePath(file) FilesystemAssetstoreAdapter.getLocalFilePath = origGetLocalFilePath self.assertTrue(os.path.exists(filepath)) self.assertTrue(os.path.exists(fusepath)) self.assertEqual(filepath, fusepath)