diff --git a/src/czitools/_tests/test_napari_tools.py b/src/czitools/_tests/test_napari_tools.py index 3537a12..38c3513 100644 --- a/src/czitools/_tests/test_napari_tools.py +++ b/src/czitools/_tests/test_napari_tools.py @@ -3,7 +3,7 @@ import numpy as np import napari from pathlib import Path -from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping +from typing import List, Dict, Tuple, Optional, Type, Any, Union, Mapping, Literal import os # check if the test in executed as part of a GITHUB action @@ -33,13 +33,17 @@ def test_rename_sliders( # exclude the test when executed inside a GITHUB action @pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test doesn't work in Github Actions.") @pytest.mark.parametrize( - "czifile, num_layers", + "czifile, num_layers, show_metadata, wdname", [ - ("w96_A1+A2.czi", 2), + ("w96_A1+A2.czi", 2, "tree", "MetadataTree"), + ("CellDivision_T=3_Z=5_CH=2_X=240_Y=170.czi", 2, "table", "MetadataTable"), ], ) -def test_show_image(czifile: str, num_layers: int) -> None: - """Test that the `show` function correctly displays a two-channel image.""" +def test_show_image(czifile: str, + num_layers: int, + show_metadata: Literal["none", "tree", "table"], + wdname: str) -> None: + """Test that the `show` function correctly displays a two-channel image and the metadada widgets.""" filepath = basedir / "data" / czifile md = metadata_tools.CziMetadata(filepath) @@ -63,10 +67,13 @@ def test_show_image(czifile: str, num_layers: int) -> None: blending="additive", contrast="from_czi", gamma=0.85, - show_metadata="tree", + show_metadata=show_metadata, name_sliders=True, ) + # Check that a tree widget is visible in the viewer + assert (wdname in viewer.window.__dict__["_dock_widgets"].data.keys()) is True + # Check that the layer is present in the viewer assert len(viewer.layers) == num_layers @@ -75,6 +82,6 @@ def test_show_image(czifile: str, num_layers: int) -> None: assert isinstance(viewer.layers[layer], napari.layers.Image) # Check that the layer's data is the same as the input image - np.testing.assert_array_equal(viewer.layers[layer].data, array6d[:, :, layer:layer+1, :, :, :]) + np.testing.assert_array_equal(viewer.layers[layer].data, array6d[:, :, layer:layer + 1, :, :, :]) viewer.close() diff --git a/src/czitools/napari_tools.py b/src/czitools/napari_tools.py index 5f36f33..4aca891 100644 --- a/src/czitools/napari_tools.py +++ b/src/czitools/napari_tools.py @@ -151,7 +151,6 @@ def show( - "napari_auto" : Let Napari figure out a display scaling. Will look in the center of an image! - "from_czi" : use the display scaling from ZEN stored inside the CZI metadata. Defaults to "calc". gamma (float, optional): gamma value for the Viewer for all layers Defaults to 0.85. - add_mdtable (bool, optional): option to show the CziMetadata. Defaults to True. show_metadata (mdviewoption, optional): Option to show metadata as tree or table. Defaults to "tree". name_sliders (bool, optional): option to use the dimension letters as slider labels for the viewer. Defaults to False. dask_cache_size(float, optional): option to resize the dask cache used for opportunistic caching. Range [0 - 1]