Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce test data size and relax test timouts #162

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
name: ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Run all supported Python versions on linux
python-version: ["3.10", "3.11", "3.12"]
Expand Down
Empty file.
13 changes: 12 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import shutil
from pathlib import Path
Expand Down Expand Up @@ -58,14 +59,24 @@ def setup_preexisting_local_atlases():
("example_mouse_100um", "v1.2"),
("allen_mouse_100um", "v1.2"),
("osten_mouse_100um", "v1.1"),
("mpin_zfish_1um", "v1.0"),
]
for atlas_name, version in preexisting_atlases:
if not Path.exists(
Path.home() / f".brainglobe/{atlas_name}_{version}"
):
_ = BrainGlobeAtlas(atlas_name)

# mock an additional reference for the example mouse
atlas_path = Path.home() / ".brainglobe" / "example_mouse_100um_v1.2"
metadata_path = atlas_path / "metadata.json"
if metadata_path.exists():
with open(metadata_path, "r") as f:
metadata = f.read()
metadata_dict = json.loads(metadata)
metadata_dict["additional_references"] = ["reference"]
with open(metadata_path, "w") as f:
json.dump(metadata_dict, f, indent=4)


@pytest.fixture
def double_click_on_view(qtbot):
Expand Down
8 changes: 5 additions & 3 deletions tests/test_integration/test_brainrender_viewer_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ def test_add_additional_reference_selected(viewer_widget, mocker):
"brainrender_napari.brainrender_viewer_widget"
".NapariAtlasRepresentation.add_additional_reference"
)
viewer_widget.atlas_viewer_view.selectRow(5) # mpin_zfish_1um is in row 5
viewer_widget.atlas_viewer_view.selectRow(
0
) # # example atlas + mock additional reference is in row 0
assert (
viewer_widget.atlas_viewer_view.selected_atlas_name()
== "mpin_zfish_1um"
== "example_mouse_100um"
)
additional_reference_name = "GAD1b"
additional_reference_name = "reference"
viewer_widget.atlas_viewer_view.additional_reference_requested.emit(
additional_reference_name
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit/test_atlas_manager_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_update_atlas_confirmed(

with qtbot.waitSignal(
atlas_manager_view.update_atlas_confirmed,
timeout=150000, # assumes atlas can be updated in 2.5 minutes!
timeout=300000, # assumes atlas can be updated in 5 minutes!
) as update_atlas_confirmed_signal:
# replace with double-click on view?
model_index = atlas_manager_view.model().index(0, 0)
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_download_confirmed_callback(atlas_manager_view, qtbot):

with qtbot.waitSignal(
atlas_manager_view.download_atlas_confirmed,
timeout=150000, # assumes atlas can be installed in 2.5 minutes!
timeout=300000, # assumes atlas can be installed in 5 minutes!
) as download_atlas_confirmed_signal:
model_index = atlas_manager_view.model().index(0, 0)
atlas_manager_view.setCurrentIndex(model_index)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_unit/test_atlas_viewer_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,27 @@ def test_double_click_on_locally_available_atlas_row(
def test_additional_reference_menu(atlas_viewer_view, qtbot, mocker):
"""Checks callback to additional reference menu calls QMenu exec
and emits expected signal"""
atlas_viewer_view.selectRow(5) # mpin_zfish_1um is in row 5
atlas_viewer_view.selectRow(
0
) # example atlas + mock additional reference is in row 0
from qtpy.QtCore import QPoint
from qtpy.QtWidgets import QAction

x = atlas_viewer_view.rowViewportPosition(5)
x = atlas_viewer_view.rowViewportPosition(0)
y = atlas_viewer_view.columnViewportPosition(1)
position = QPoint(x, y)
qmenu_exec_mock = mocker.patch(
"brainrender_napari.widgets.atlas_viewer_view.QMenu.exec"
)
qmenu_exec_mock.return_value = QAction("mock_additional_reference")
qmenu_exec_mock.return_value = QAction("reference")

with qtbot.waitSignal(
atlas_viewer_view.additional_reference_requested
) as additional_reference_requested_signal:
atlas_viewer_view.customContextMenuRequested.emit(position)

qmenu_exec_mock.assert_called_once()
assert additional_reference_requested_signal.args == [
"mock_additional_reference"
]
assert additional_reference_requested_signal.args == ["reference"]


def test_get_tooltip():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit/test_napari_atlas_representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def test_structure_color(make_napari_viewer):

def test_add_additional_reference(make_napari_viewer):
viewer = make_napari_viewer()
atlas_name = "mpin_zfish_1um"
additional_reference_name = "GAD1b"
atlas_name = "example_mouse_100um"
additional_reference_name = "reference"
atlas = BrainGlobeAtlas(atlas_name=atlas_name)

atlas_representation = NapariAtlasRepresentation(atlas, viewer)
Expand Down
Loading