Skip to content

Commit

Permalink
renable some registration loading tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson committed Jul 25, 2024
1 parent 8da43f9 commit 7174b50
Showing 1 changed file with 88 additions and 92 deletions.
180 changes: 88 additions & 92 deletions tests/tests/test_brainmapper/test_transform_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ def mock_display_info(mocker):
# return transformation_widget_with_data


# @pytest.fixture(scope="function")
# def transformation_widget_with_data(
# transformation_widget_with_napari_layers, brainreg_directory
# ):
# transformation_widget_with_napari_layers.brainreg_directory = (
# brainreg_directory
# )
# transformation_widget_with_napari_layers.initialise_brainreg_data()
# return transformation_widget_with_napari_layers
@pytest.fixture(scope="function")
def transformation_widget_with_data(
transformation_widget_with_napari_layers, brainreg_directory
):
transformation_widget_with_napari_layers.brainreg_directory = (
brainreg_directory
)
transformation_widget_with_napari_layers.initialise_brainreg_data()
return transformation_widget_with_napari_layers


@pytest.fixture(scope="function")
Expand Down Expand Up @@ -209,33 +209,33 @@ def dummy_brainreg_file_paths(dummy_brainreg_directory) -> Paths:
return Paths(dummy_brainreg_directory)


# def test_initialise_brainreg_data(
# transformation_widget_with_data, brainreg_directory
# ):
#
# assert (
# transformation_widget_with_data.paths.brainreg_directory
# == brainreg_directory
# )
# assert (
# transformation_widget_with_data.metadata.orientation
# == ATLAS_ORIENTATION
# )
# assert (
# transformation_widget_with_data.atlas.atlas_name ==
# "allen_mouse_50um"
# )
#
#
# def test_get_downsampled_space(transformation_widget_with_data):
# downsampled_space =
# transformation_widget_with_data.get_downsampled_space()
# assert downsampled_space.origin_string == ATLAS_ORIENTATION
#
#
# def test_get_raw_data_space(transformation_widget_with_data):
# raw_data_space = transformation_widget_with_data.get_raw_data_space()
# assert raw_data_space.origin_string == RAW_DATA_ORIENTATION
def test_initialise_brainreg_data(
transformation_widget_with_data, brainreg_directory
):

assert (
transformation_widget_with_data.paths.brainreg_directory
== brainreg_directory
)
assert (
transformation_widget_with_data.metadata.orientation
== ATLAS_ORIENTATION
)
assert (
transformation_widget_with_data.atlas.atlas_name == "allen_mouse_50um"
)


def test_get_downsampled_space(transformation_widget_with_data):
downsampled_space = transformation_widget_with_data.get_downsampled_space()
assert downsampled_space.origin_string == ATLAS_ORIENTATION


def test_get_raw_data_space(transformation_widget_with_data):
raw_data_space = transformation_widget_with_data.get_raw_data_space()
assert raw_data_space.origin_string == RAW_DATA_ORIENTATION


#
#
# def test_call_transform_points_to_atlas_space(
Expand Down Expand Up @@ -344,23 +344,22 @@ 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(
transformation_widget_with_napari_layers, mocker
):
Expand All @@ -376,45 +375,42 @@ 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_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_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_display_brainreg_directory_warning_calls_display_info(
transformation_widget_with_napari_layers, mock_display_info
):
Expand Down

0 comments on commit 7174b50

Please sign in to comment.