From f91f3803452704607bcf0c67f5f73192a0b6e23a Mon Sep 17 00:00:00 2001 From: fdrgsp Date: Mon, 4 Mar 2024 16:48:43 -0500 Subject: [PATCH] test: fix tests --- tests/conftest.py | 12 ++++++------ tests/test_layer_scale.py | 6 ------ tests/test_multid_widget.py | 8 +++----- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index bddfb5c3..bb2bc8e6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 @@ -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 diff --git a/tests/test_layer_scale.py b/tests/test_layer_scale.py index 758c4360..5f236f3b 100644 --- a/tests/test_layer_scale.py +++ b/tests/test_layer_scale.py @@ -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 @@ -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) diff --git a/tests/test_multid_widget.py b/tests/test_multid_widget.py index f4c204d0..bd2414b1 100644 --- a/tests/test_multid_widget.py +++ b/tests/test_multid_widget.py @@ -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: @@ -17,7 +17,6 @@ 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) @@ -25,8 +24,8 @@ def test_main_window_mda(main_window: MainWindow): 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) @@ -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):