Skip to content

Commit

Permalink
Enable more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson committed Jul 25, 2024
1 parent 3a23419 commit 2606735
Showing 1 changed file with 62 additions and 70 deletions.
132 changes: 62 additions & 70 deletions tests/tests/test_brainmapper/test_transform_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,24 @@ def test_call_transform_points_to_atlas_space(
# )
#
#
# def test_transformation_raises_info_points_out_of_bounds(
# transformation_widget_with_data, mock_display_info
# ):
# points_layer = transformation_widget_with_data.viewer.add_points(
# points_outside_brain
# )
# transformation_widget_with_data.points_layer = points_layer
# transformation_widget_with_data.
# run_transform_points_to_downsampled_space()
# transformation_widget_with_data.
# run_transform_downsampled_points_to_atlas_space()
# mock_display_info.assert_called_once_with(
# transformation_widget_with_data,
# "Points outside atlas",
# "2 points fell outside the atlas space",
# )
def test_transformation_raises_info_points_out_of_bounds(
transformation_widget_with_data, mock_display_info
):
points_layer = transformation_widget_with_data.viewer.add_points(
points_outside_brain
)
transformation_widget_with_data.points_layer = points_layer
transformation_widget_with_data.run_transform_points_to_downsampled_space()
transformation_widget_with_data.run_transform_downsampled_points_to_atlas_space()
mock_display_info.assert_called_once_with(
transformation_widget_with_data,
"Points outside atlas",
"2 points fell outside the atlas space",
)


# def test_check_layers(transformation_widget_with_data):
# assert transformation_widget_with_data.check_layers()
def test_check_layers(transformation_widget_with_data):
assert transformation_widget_with_data.check_layers()


def test_check_layers_no_layers(transformation_widget, mock_display_info):
Expand Down Expand Up @@ -349,21 +347,20 @@ def test_check_layers_no_points_data(
)


# def test_load_brainreg_directory(
# transformation_widget_with_napari_layers, brainreg_directory, mocker
# ):
# # Mock dialog to avoid need for UI
# mock_get_save_file_name = mocker.patch(
# "brainglobe_utils.brainmapper.transform_widget.
# QFileDialog.getExistingDirectory"
# )
# mock_get_save_file_name.return_value = brainreg_directory
#
# transformation_widget_with_napari_layers.load_brainreg_directory()
# assert (
# transformation_widget_with_napari_layers.atlas.atlas_name
# == "allen_mouse_50um"
# )
def test_load_brainreg_directory(
transformation_widget_with_napari_layers, brainreg_directory, mocker
):
# Mock dialog to avoid need for UI
mock_get_save_file_name = mocker.patch(
"brainglobe_utils.brainmapper.transform_widget.QFileDialog.getExistingDirectory"
)
mock_get_save_file_name.return_value = brainreg_directory

transformation_widget_with_napari_layers.load_brainreg_directory()
assert (
transformation_widget_with_napari_layers.atlas.atlas_name
== "allen_mouse_50um"
)


def test_load_brainreg_directory_no_input(
Expand All @@ -381,45 +378,40 @@ def test_load_brainreg_directory_no_input(
)


# def test_check_brainreg_directory_correct_metadata(
# mocker, transformation_widget_with_data
# ):
# mock_method = mocker.patch.object(
# transformation_widget_with_data,
# "display_brainreg_directory_warning"
# )
#
# transformation_widget_with_data.check_brainreg_directory()
# mock_method.assert_not_called()
def test_check_brainreg_directory_correct_metadata(
mocker, transformation_widget_with_data
):
mock_method = mocker.patch.object(
transformation_widget_with_data, "display_brainreg_directory_warning"
)

transformation_widget_with_data.check_brainreg_directory()
mock_method.assert_not_called()

# def test_check_brainreg_directory_random_data(
# mocker, transformation_widget_with_data, random_json_path
# ):
# mock_method = mocker.patch.object(
# transformation_widget_with_data,
# "display_brainreg_directory_warning"
# )
# transformation_widget_with_data.paths.brainreg_metadata_file = (
# random_json_path
# )
# transformation_widget_with_data.check_brainreg_directory()
# mock_method.assert_called_once()
#
#
# def test_check_brainreg_directory_false_path(
# mocker, transformation_widget_with_data
# ):
# mock_method = mocker.patch.object(
# transformation_widget_with_data,
# "display_brainreg_directory_warning"
# )
#
# transformation_widget_with_data.paths.brainreg_metadata_file
# = "/some/file"
# transformation_widget_with_data.check_brainreg_directory()
# mock_method.assert_called_once()
#

def test_check_brainreg_directory_random_data(
mocker, transformation_widget_with_data, random_json_path
):
mock_method = mocker.patch.object(
transformation_widget_with_data, "display_brainreg_directory_warning"
)
transformation_widget_with_data.paths.brainreg_metadata_file = (
random_json_path
)
transformation_widget_with_data.check_brainreg_directory()
mock_method.assert_called_once()


def test_check_brainreg_directory_false_path(
mocker, transformation_widget_with_data
):
mock_method = mocker.patch.object(
transformation_widget_with_data, "display_brainreg_directory_warning"
)

transformation_widget_with_data.paths.brainreg_metadata_file = "/some/file"
transformation_widget_with_data.check_brainreg_directory()
mock_method.assert_called_once()


def test_display_brainreg_directory_warning_calls_display_info(
Expand Down

0 comments on commit 2606735

Please sign in to comment.