Skip to content

Commit

Permalink
Add commented out test
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Oct 21, 2024
1 parent 3294404 commit 1899d5d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/devices/unit_tests/oav/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ async def oav() -> OAV:
oav = OAV("", config=oav_config, name="fake_oav")
set_mock_value(oav.grid_snapshot.x_size, 1024)
set_mock_value(oav.grid_snapshot.y_size, 768)
set_mock_value(oav.zoom_controller.level, "1.0x")
return oav
47 changes: 46 additions & 1 deletion tests/devices/unit_tests/oav/test_oav_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from bluesky.run_engine import RunEngine
from ophyd.sim import instantiate_fake_device

# from ophyd_async.core import set_mock_value
from dodal.devices.oav.oav_calculations import calculate_beam_distance
from dodal.devices.oav.oav_detector import OAV
from dodal.devices.oav.pin_image_recognition import PinTipDetection
Expand All @@ -13,8 +14,11 @@
PinNotFoundException,
bottom_right_from_top_left,
wait_for_tip_to_be_found,
# get_move_required_so_that_beam_is_at_pixel,
)

# from dodal.devices.smargon import Smargon


def test_bottom_right_from_top_left():
top_left = np.array([123, 123])
Expand Down Expand Up @@ -45,7 +49,48 @@ def test_calculate_beam_distance(h, v, expected_x, expected_y, oav: OAV):
) == (expected_x, expected_y)


# TODO add test_values_for_move_so_that_beam_is_at_pixel
# TODO, can't set beam center and micron as I want, will need to calculate
# the right values.
# @pytest.mark.parametrize(
# "px_per_um, beam_centre, angle, pixel_to_move_to, expected_xyz",
# [
# # Simple case of beam being in the top left and each pixel being 1 mm
# ([1000, 1000], [0, 0], 0, [100, 190], [100, 190, 0]),
# ([1000, 1000], [0, 0], -90, [50, 250], [50, 0, 250]),
# ([1000, 1000], [0, 0], 90, [-60, 450], [-60, 0, -450]),
# # Beam offset
# ([1000, 1000], [100, 100], 0, [100, 100], [0, 0, 0]),
# ([1000, 1000], [100, 100], -90, [50, 250], [-50, 0, 150]),
# # Pixels_per_micron different
# ([10, 50], [0, 0], 0, [100, 190], [1, 9.5, 0]),
# ([60, 80], [0, 0], -90, [50, 250], [3, 0, 20]),
# ],
# )
# async def test_values_for_move_so_that_beam_is_at_pixel(
# smargon: Smargon,
# oav: OAV,
# px_per_um,
# beam_centre,
# angle,
# pixel_to_move_to,
# expected_xyz,
# ):
# await oav.microns_per_pixel_x._backend.put(px_per_um[0])
# # set_mock_value(oav.microns_per_pixel_x, px_per_um[0])
# set_mock_value(oav.microns_per_pixel_y, px_per_um[1])
# set_mock_value(oav.beam_centre_i, beam_centre[0])
# set_mock_value(oav.beam_centre_j, beam_centre[1])

# set_mock_value(smargon.omega.user_readback, angle)

# RE = RunEngine(call_returns_result=True)
# pos = RE(
# get_move_required_so_that_beam_is_at_pixel(
# smargon, pixel_to_move_to, oav
# )
# ).plan_result # type: ignore

# assert pos == pytest.approx(expected_xyz)


@pytest.mark.asyncio
Expand Down

0 comments on commit 1899d5d

Please sign in to comment.