Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fdrgsp committed Mar 4, 2024
1 parent 39a73c3 commit f91f380
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
import useq
from napari_micromanager._mda_meta import SEQUENCE_META_KEY, SequenceMeta
from napari_micromanager._gui_objects._mda_widget import NAPARI_MM_META
from napari_micromanager.main_window import MainWindow
from pymmcore_plus import CMMCorePlus

Expand Down Expand Up @@ -44,14 +44,14 @@ def main_window(core: CMMCorePlus, make_napari_viewer):

@pytest.fixture(params=MDAS, ids=MDA_IDS)
def mda_sequence(request: pytest.FixtureRequest) -> useq.MDASequence:
seq_meta = SequenceMeta(mode="mda")
return useq.MDASequence(**request.param, metadata={SEQUENCE_META_KEY: seq_meta})
return useq.MDASequence(
**request.param, metadata={NAPARI_MM_META: {"split_channels": False}}
)


@pytest.fixture(params=[True, False], ids=["splitC", "no_splitC"])
def mda_sequence_splits(mda_sequence: useq.MDASequence, request) -> useq.MDASequence:
if request.param:
meta: SequenceMeta = mda_sequence.metadata[SEQUENCE_META_KEY]
meta = meta.replace(split_channels=True)
mda_sequence.metadata[SEQUENCE_META_KEY] = meta
meta = {"split_channels": True}
mda_sequence.metadata[NAPARI_MM_META] = meta
return mda_sequence
6 changes: 0 additions & 6 deletions tests/test_layer_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest
from napari_micromanager._mda_handler import _NapariMDAHandler
from napari_micromanager._mda_meta import SEQUENCE_META_KEY, SequenceMeta

if TYPE_CHECKING:
from napari_micromanager.main_window import MainWindow
Expand All @@ -30,11 +29,6 @@ def test_layer_scale(
)
z_step = sequence.z_plan and sequence.z_plan.step

# the MDASequence 'replace' switchesp the metadata to a dict, here we switch it back
meta = sequence.metadata[SEQUENCE_META_KEY]
meta = SequenceMeta(**meta)
sequence = sequence.replace(metadata={SEQUENCE_META_KEY: meta})

# create zarr layer
handler._on_mda_started(sequence)

Expand Down
8 changes: 3 additions & 5 deletions tests/test_multid_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from napari_micromanager._mda_meta import SEQUENCE_META_KEY, SequenceMeta
from napari_micromanager._gui_objects._mda_widget import NAPARI_MM_META
from useq import MDASequence

if TYPE_CHECKING:
Expand All @@ -17,16 +17,15 @@ def test_main_window_mda(main_window: MainWindow):
time_plan={"loops": 4, "interval": 0.1},
z_plan={"range": 3, "step": 1},
channels=["DAPI", "FITC"],
metadata={SEQUENCE_META_KEY: SequenceMeta(mode="mda")},
)

main_window._mmc.mda.run(mda)
assert main_window.viewer.layers[-1].data.shape == (4, 2, 4, 512, 512)
assert main_window.viewer.layers[-1].data.nchunks_initialized == 32

# assert that the layer has the correct metadata
layer_meta = main_window.viewer.layers[0].metadata.get(SEQUENCE_META_KEY)
keys = ["mode", "useq_sequence", "uid"]
layer_meta = main_window.viewer.layers[0].metadata.get(NAPARI_MM_META)
keys = ["useq_sequence", "uid"]
assert all(key in layer_meta for key in keys)


Expand All @@ -39,7 +38,6 @@ def test_script_initiated_mda(main_window: MainWindow, qtbot: QtBot):
z_plan={"range": 4, "step": 5},
axis_order="tpcz",
stage_positions=[(222, 1, 1), (111, 0, 0)],
metadata={SEQUENCE_META_KEY: SequenceMeta(mode="mda")},
)

with qtbot.waitSignal(mmc.mda.events.sequenceFinished, timeout=5000):
Expand Down

0 comments on commit f91f380

Please sign in to comment.