def testGetLargeImagePath(server, admin, fsAssetstore): file = utilities.uploadExternalFile('data/sample_image.ptif.sha512', admin, fsAssetstore) itemId = str(file['itemId']) item = Item().load(itemId, user=admin) ts = ImageItem().tileSource(item) with mock.patch.object(File(), 'getGirderMountFilePath', return_value='mockmount'): path = ts._getLargeImagePath() abspath = os.path.abspath(path) assert path != file['path'] assert path.endswith(file['path']) ts._mayHaveAdjacentFiles = True path = ts._getLargeImagePath() assert path == 'mockmount' origFile = file file['imported'] = True file['path'] = abspath file = File().save(file) path = ts._getLargeImagePath() assert path == abspath file = File().save(origFile)
def _resolveSourcePath(self, sources, source): try: super()._resolveSourcePath(sources, source) except TileSourceFileNotFoundError: prefix = 'girder://' potentialId = source['path'] if potentialId.startswith(prefix): potentialId = potentialId[len(prefix):] if '://' not in potentialId: try: item = ImageItem().load(potentialId, force=True) ts = ImageItem().tileSource(item) source = copy.deepcopy(source) source['path'] = ts._getLargeImagePath() source['sourceName'] = item['largeImage']['sourceName'] sources.append(source) return except Exception: pass raise