From 84d236d1951f06f147a4551ce8ba7ca91ebd2540 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Tue, 12 Nov 2024 08:22:44 +0000 Subject: [PATCH] Update for latest ophyd-async version (#629) * Update for latest ophyd-async version * Pin dodal --- pyproject.toml | 4 ++-- src/mx_bluesky/common/test_utils.py | 18 ------------------ tests/conftest.py | 2 +- tests/unit_tests/beamlines/i04/test_thawing.py | 9 ++------- 4 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 src/mx_bluesky/common/test_utils.py diff --git a/pyproject.toml b/pyproject.toml index 21420c492..f78780997 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "ophyd == 1.9.0", "ophyd-async >= 0.3a5", "bluesky >= 1.13.0a4", - "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@main", + "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@19ce6d9cec962329b906f36b583e404a9283efe3", ] @@ -108,7 +108,7 @@ version_file = "src/mx_bluesky/_version.py" [tool.pyright] typeCheckingMode = "standard" -reportMissingImports = false # Ignore missing stubs in imported modules +reportMissingImports = false # Ignore missing stubs in imported modules [tool.pytest.ini_options] # Run pytest with all our checkers, and don't spam us with massive tracebacks on error diff --git a/src/mx_bluesky/common/test_utils.py b/src/mx_bluesky/common/test_utils.py deleted file mode 100644 index 060e16d32..000000000 --- a/src/mx_bluesky/common/test_utils.py +++ /dev/null @@ -1,18 +0,0 @@ -from collections.abc import Callable -from typing import TypeVar - -from dodal.common.beamlines.beamline_utils import clear_device -from ophyd_async.core import Device - -OADevice = TypeVar("OADevice", bound=Device) - - -def rebuild_oa_device_as_mocked_if_necessary(factory: Callable[[], OADevice], **kwargs): - """Rebuild the device if it was previously connected as real not fake - this - is usually due to being instantiated as a default parameter value to a bluesky plan - on module load""" - device = factory(**kwargs) - if not device._connect_mock_arg: # noqa - clear_device(device.name) - device = factory(**kwargs) - return device diff --git a/tests/conftest.py b/tests/conftest.py index 3e9bccf65..d9b0b008c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -59,8 +59,8 @@ callback_on_mock_put, set_mock_value, ) +from ophyd_async.epics.core import epics_signal_rw from ophyd_async.epics.motor import Motor -from ophyd_async.epics.signal import epics_signal_rw from ophyd_async.fastcs.panda import DatasetTable, PandaHdf5DatasetType from scanspec.core import Path as ScanPath from scanspec.specs import Line diff --git a/tests/unit_tests/beamlines/i04/test_thawing.py b/tests/unit_tests/beamlines/i04/test_thawing.py index 29acf4d8e..d180b23ba 100644 --- a/tests/unit_tests/beamlines/i04/test_thawing.py +++ b/tests/unit_tests/beamlines/i04/test_thawing.py @@ -23,7 +23,6 @@ from ophyd_async.epics.motor import Motor from mx_bluesky.beamlines.i04.thawing_plan import thaw, thaw_and_stream_to_redis -from mx_bluesky.common.test_utils import rebuild_oa_device_as_mocked_if_necessary DISPLAY_CONFIGURATION = "tests/test_data/test_display.configuration" ZOOM_LEVELS_XML = "tests/test_data/test_jCameraManZoomLevels.xml" @@ -73,9 +72,7 @@ async def smargon(RE: RunEngine) -> AsyncGenerator[Smargon, None]: @pytest.fixture def thawer(RE: RunEngine) -> Thawer: - return rebuild_oa_device_as_mocked_if_necessary( - i04.thawer, fake_with_ophyd_sim=True, wait_for_connection=True - ) + return i04.thawer(fake_with_ophyd_sim=True, wait_for_connection=True) @pytest.fixture @@ -97,9 +94,7 @@ async def completed_status(): @pytest.fixture def robot(RE: RunEngine) -> BartRobot: - return rebuild_oa_device_as_mocked_if_necessary( - i04.robot, wait_for_connection=True, fake_with_ophyd_sim=True - ) + return i04.robot(wait_for_connection=True, fake_with_ophyd_sim=True) def _do_thaw_and_confirm_cleanup(