def test_GirderFileIdToVolume_cleanup_removes_filepath(mock_gc, patch_mkdir, bogus_volume): gfitv = GirderFileIdToVolume('BOGUS_ID', volume=bogus_volume, gc=mock_gc) gfitv.transform() with mock.patch('girder_worker.docker.transforms.girder.shutil.rmtree') as mock_rmtree: gfitv.cleanup() mock_rmtree.assert_called_once_with( os.path.join(BOGUS_HOST_PATH, 'BOGUS_ID', 'bogus.txt'), ignore_errors=True)
def test_GirderFileIdToVolume_transform_returns_volume_container_path_plus_id_plus_name( mock_gc, patch_mkdir, bogus_volume): gfitv = GirderFileIdToVolume('BOGUS_ID', volume=bogus_volume, gc=mock_gc) assert gfitv.transform() == os.path.join(BOGUS_CONTAINER_PATH, 'BOGUS_ID', 'bogus.txt') patch_mkdir.assert_called_once_with( os.path.join(BOGUS_HOST_PATH, 'BOGUS_ID'))
def test_GirderFileIdToVolume_transform_respects_filename_if_passed( mock_gc, bogus_volume): gfitv = GirderFileIdToVolume('BOGUS_ID', volume=bogus_volume, filename='foo.txt', gc=mock_gc) assert gfitv.transform() == os.path.join(BOGUS_CONTAINER_PATH, 'foo.txt') mock_gc.downloadFile.assert_called_once_with( 'BOGUS_ID', os.path.join(BOGUS_HOST_PATH, 'foo.txt'))
def test_GirderFileIdToVolume_transform_calls_gc_downloadFile( mock_gc, patch_mkdir, bogus_volume): gfitv = GirderFileIdToVolume('BOGUS_ID', volume=bogus_volume, gc=mock_gc) gfitv.transform() mock_gc.downloadFile.assert_called_once_with( 'BOGUS_ID', os.path.join(BOGUS_HOST_PATH, 'BOGUS_ID', 'bogus.txt'))