Skip to content

Commit

Permalink
Expose check_and_cache_values required for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Sep 19, 2024
1 parent 644a9fd commit 2021d8b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/dodal/plan_stubs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from .data_session_metadata import attach_data_session_metadata_decorator
from .motor_util_plans import (
MoveTooLarge,
check_and_cache_values,
home_and_reset_decorator,
home_and_reset_wrapper,
move_and_reset_wrapper,
)

__all__ = [
"check_and_cache_values",
"check_topup_and_wait_if_necessary",
"wait_for_topup_complete",
"attach_data_session_metadata_decorator",
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/plan_stubs/motor_util_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
super().__init__(*args)


def _check_and_cache_values(
def check_and_cache_values(
devices_and_positions: dict[AnyDevice, float],
smallest_move: float,
maximum_move: float,
Expand Down Expand Up @@ -87,7 +87,7 @@ def move_and_reset_wrapper(
on. If false it is left up to the caller to wait on
them. Defaults to True.
"""
initial_positions = yield from _check_and_cache_values(
initial_positions = yield from check_and_cache_values(
device_and_positions, smallest_move, maximum_move
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from ophyd_async.epics.motor import Motor

from dodal.devices.util.test_utils import patch_motor
from dodal.plans.motor_util_plans import (
from dodal.plan_stubs import (
MoveTooLarge,
_check_and_cache_values,
check_and_cache_values,
home_and_reset_wrapper,
)

Expand Down Expand Up @@ -80,7 +80,7 @@ def test_given_a_device_when_check_and_cache_values_then_motor_values_returned(
set_mock_value(motor.user_readback, i * 100)

motors_and_positions: dict[Motor, float] = RE(
_check_and_cache_values(
check_and_cache_values(
{motor_obj: 0.0 for motor_obj in my_device.motors}, 0, 1000
)
).plan_result # type: ignore
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_given_a_device_with_a_too_large_move_when_check_and_cache_values_then_e
motors_and_positions = {motor_obj: new_position for motor_obj in my_device.motors}

with pytest.raises(MoveTooLarge) as e:
RE(_check_and_cache_values(motors_and_positions, 0, max))
RE(check_and_cache_values(motors_and_positions, 0, max))
assert e.value.axis == my_device.y
assert e.value.maximum_move == max

Expand All @@ -136,7 +136,7 @@ def test_given_a_device_where_one_move_too_small_when_check_and_cache_values_the
}

motors_and_positions: dict[Motor, float] = RE(
_check_and_cache_values(motors_and_new_positions, min, 1000)
check_and_cache_values(motors_and_new_positions, min, 1000)
).plan_result # type: ignore
cached_positions = motors_and_positions.values()

Expand All @@ -156,7 +156,7 @@ def test_given_a_device_where_all_moves_too_small_when_check_and_cache_values_th
motors_and_new_positions = {motor_obj: 0.0 for motor_obj in my_device.motors}

motors_and_positions: dict[Motor, float] = RE(
_check_and_cache_values(motors_and_new_positions, 40, 1000)
check_and_cache_values(motors_and_new_positions, 40, 1000)
).plan_result # type: ignore
cached_positions = motors_and_positions.values()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from dodal.beamlines import i03
from dodal.devices.synchrotron import Synchrotron, SynchrotronMode
from dodal.plans.check_topup import (
from dodal.plan_stubs import (
check_topup_and_wait_if_necessary,
wait_for_topup_complete,
)
Expand Down

0 comments on commit 2021d8b

Please sign in to comment.