diff --git a/openatlas/api/routes.py b/openatlas/api/routes.py index bf18cb7ae..f9afe15b6 100644 --- a/openatlas/api/routes.py +++ b/openatlas/api/routes.py @@ -106,13 +106,13 @@ def add_routes_v03(api: Api) -> None: endpoint='iiif_manifest') api.add_resource( IIIFImageV2, - '/iiif_image//.json', + '/iiif_image/.json', endpoint='iiif_image') api.add_resource( IIIFCanvasV2, - '/iiif_canvas//.json', + '/iiif_canvas/.json', endpoint='iiif_canvas') api.add_resource( IIIFSequenceV2, - '/iiif_sequence//.json', + '/iiif_sequence/.json', endpoint='iiif_sequence') diff --git a/openatlas/display/image_processing.py b/openatlas/display/image_processing.py index cfa91f813..748951037 100644 --- a/openatlas/display/image_processing.py +++ b/openatlas/display/image_processing.py @@ -33,7 +33,7 @@ def image_resizing(name: str, format_: str, size: str) -> bool: filename = Path(app.config['UPLOAD_PATH']) / f"{name}{format_}[0]" with Image(filename=filename) as src: if format_ in app.config['PROCESSABLE_EXT']: - format_ = app.config['PROCESSED_EXT'] + format_ = app.config['PROCESSED_EXT'] # pragma: no cover with src.convert(format_.replace('.', '')) as img: img.transform(resize=f"{size}x{size}>") img.compression_quality = 75 @@ -62,7 +62,7 @@ def check_processed_image(filename: str) -> bool: def loop_through_processed_folders(name: str, file_format: str) -> bool: ext = file_format if file_format in app.config['PROCESSABLE_EXT']: - ext = app.config['PROCESSED_EXT'] + ext = app.config['PROCESSED_EXT'] # pragma: no cover for size in app.config['IMAGE_SIZE'].values(): path = Path(app.config['RESIZED_IMAGES']) / size / f"{name}{ext}" if not path.is_file() \ diff --git a/openatlas/display/util.py b/openatlas/display/util.py index d2dbf8e70..92781c987 100644 --- a/openatlas/display/util.py +++ b/openatlas/display/util.py @@ -783,5 +783,5 @@ def convert_image_to_iiif(id_: int) -> None: process = subprocess.Popen(command, shell=True) process.wait() flash(_('IIIF converted'), 'info') - except Exception as e: + except Exception as e: # pragma: no cover flash(f"{_('failed to convert image')}: {e}", 'error') diff --git a/openatlas/views/entity_index.py b/openatlas/views/entity_index.py index c4c052913..4da44ba4d 100644 --- a/openatlas/views/entity_index.py +++ b/openatlas/views/entity_index.py @@ -85,7 +85,7 @@ def file_preview(entity_id: int) -> str: url = (f"{app.config['IIIF']['url']}{entity_id}{ext}" f"/full/!100,100/0/default.jpg") return f"" \ - if ext in app.config["IIIF_IMAGE_EXT"] else '' + if ext in g.display_file_ext else '' if icon_path := get_file_path( entity_id, app.config['IMAGE_SIZE']['table']): diff --git a/openatlas/views/file.py b/openatlas/views/file.py index 639467b11..1bd295d49 100644 --- a/openatlas/views/file.py +++ b/openatlas/views/file.py @@ -80,8 +80,9 @@ def make_iiif_available(id_: int) -> Response: def view_iiif(id_: int) -> str: return render_template( 'iiif.html', - manifest_url=url_for( - 'api.iiif_manifest', - id_=id_, - version=app.config['IIIF']['version'], - _external=True)) + manifest_url= + url_for( + 'api.iiif_manifest', + id_=id_, + version=app.config['IIIF']['version'], + _external=True)) diff --git a/tests/test_file.py b/tests/test_file.py index 4be5826bd..e3489b0e1 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -101,17 +101,53 @@ def test_file(self) -> None: follow_redirects=True) assert b'Updated file' in rv.data + rv = self.app.get(url_for('view', id_=file_id)) + assert b'Logo' in rv.data + + rv = self.app.get(url_for('view', id_=file_id)) + assert b'make_iiif_available' in rv.data + rv = self.app.get( url_for('make_iiif_available', id_=file_id), follow_redirects=True) assert b'IIIF converted' in rv.data rv = self.app.get(url_for('view', id_=file_id)) - assert b'Logo' in rv.data + assert b'iiif' in rv.data + + rv = self.app.get(url_for( + 'api.iiif_manifest', + id_=file_id, + version=app.config['IIIF']['version'], + _external=True)) + assert b'/iiif/2/145.tiff' in rv.data + + rv = self.app.get( + url_for('api.iiif_sequence', id_=file_id)) + assert b'/iiif/2/145.tiff' in rv.data + rv = self.app.get( + url_for('api.iiif_image', id_=file_id)) + assert b'/iiif/2/145.tiff' in rv.data + rv = self.app.get( + url_for('api.iiif_canvas', id_=file_id)) + assert b'/iiif/2/145.tiff' in rv.data rv = self.app.get(url_for('view_iiif', id_=file_id)) assert b'Mirador' in rv.data + rv = self.app.get(url_for('view', id_=place.id)) + assert b'/full/!100,100/0/default.jpg' in rv.data + + app.config['IIIF']['conversion'] = False + rv = self.app.get(url_for('view', id_=place.id)) + assert b'/full/!100,100/0/default.jpg' in rv.data + + app.config['IIIF']['activate'] = False + rv = self.app.get(url_for('view', id_=place.id)) + assert b'Logo' in rv.data + + app.config['IIIF']['activate'] = True + app.config['IIIF']['conversion'] = True for file in files: rv = self.app.get( url_for('delete', id_=file.id),