Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Sep 5, 2024
1 parent 50e2cbb commit fefd30b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
3 changes: 2 additions & 1 deletion brainglobe_stitch/stitching_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ def _on_fuse_button_clicked(self):

if path.suffix not in valid_extensions:
show_warning(
f"Output file name should either end with {valid_extensions}"
f"Output file name should end with "
f"{', '.join(valid_extensions)}"
)
return

Expand Down
49 changes: 22 additions & 27 deletions tests/test_unit/test_stitching_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,32 +187,6 @@ def test_set_tile_layers_multiple(stitching_widget, num_layers):
assert stitching_widget.tile_layers == test_layers


@pytest.mark.parametrize("file_name", ["fused_image.h5", "fused_image.zarr"])
def test_on_fuse_button_clicked(
make_napari_viewer_proxy, naive_bdv_directory, mocker, file_name
):
viewer = make_napari_viewer_proxy()
stitching_widget = StitchingWidget(viewer)

stitching_widget.image_mosaic = ImageMosaic(naive_bdv_directory)

mock_fuse = mocker.patch(
"brainglobe_stitch.stitching_widget.ImageMosaic.fuse",
autospec=True,
)

stitching_widget.output_file_name_field.setText(file_name)

stitching_widget._on_fuse_button_clicked()

mock_fuse.assert_called_once_with(
stitching_widget.image_mosaic,
file_name,
normalise_intensity=False,
interpolate=False,
)


def test_check_and_load_mesospim_directory(
stitching_widget, naive_bdv_directory
):
Expand Down Expand Up @@ -426,6 +400,27 @@ def test_update_tiles_from_mosaic(
assert (tile.translate == test_data[1]).all()


@pytest.mark.parametrize("file_name", ["fused_image.h5", "fused_image.zarr"])
def test_on_fuse_button_clicked(
make_napari_viewer_proxy, naive_bdv_directory, mocker, file_name
):
viewer = make_napari_viewer_proxy()
stitching_widget = StitchingWidget(viewer)

stitching_widget.image_mosaic = ImageMosaic(naive_bdv_directory)

mock_fuse = mocker.patch(
"brainglobe_stitch.stitching_widget.ImageMosaic.fuse",
autospec=True,
)

stitching_widget.output_file_name_field.setText(file_name)

stitching_widget._on_fuse_button_clicked()

mock_fuse.assert_called_once_with(stitching_widget.image_mosaic, file_name)


def test_on_fuse_button_clicked_no_file_name(
make_napari_viewer_proxy, naive_bdv_directory, mocker
):
Expand Down Expand Up @@ -453,7 +448,7 @@ def test_on_fuse_button_clicked_wrong_suffix(

stitching_widget.image_mosaic = ImageMosaic(naive_bdv_directory)
stitching_widget.output_file_name_field.setText("fused_image.tif")
error_message = "Output file name should either end with .zarr or .h5"
error_message = "Output file name should end with .zarr, .h5"

mock_show_warning = mocker.patch(
"brainglobe_stitch.stitching_widget.show_warning",
Expand Down

0 comments on commit fefd30b

Please sign in to comment.