Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Sep 2, 2024
1 parent b211e6a commit 80442d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from dodal.devices.i24.pmac import PMAC
from dodal.devices.oav.oav_detector import OAV

from mx_bluesky.beamlines.i24.serial.fixed_target import \
i24ssx_Chip_Manager_py3v1 as manager
from mx_bluesky.beamlines.i24.serial.fixed_target import (
i24ssx_Chip_Manager_py3v1 as manager,
)
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import Fiducials
from mx_bluesky.beamlines.i24.serial.parameters.constants import OAV1_CAM

Expand All @@ -31,7 +32,7 @@ def _get_beam_centre(oav: OAV):

def _calculate_zoom_calibrator(oav: OAV, RE: RunEngine):
"""Set the scale for the zoom calibrator for the pmac moves."""
currentzoom = RE(bps.rd(oav.zoom_controller.percentage)).plan_result
currentzoom = RE(bps.rd(oav.zoom_controller.percentage)).plan_result # type: ignore
zoomcalibrator = 1.547 - (0.03 * currentzoom) + (0.0001634 * currentzoom**2)
return zoomcalibrator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,34 @@
update_ui,
)

# FIXME
zoomcalibrator = 6
ZOOMCALIBRATOR = 6


@pytest.mark.parametrize(
"beam_position, expected_xmove, expected_ymove",
[
(
(15, 10),
"#1J:-" + str(15 * zoomcalibrator),
"#2J:-" + str(10 * zoomcalibrator),
"#1J:-" + str(15 * ZOOMCALIBRATOR),
"#2J:-" + str(10 * ZOOMCALIBRATOR),
),
(
(475, 309),
"#1J:-" + str(475 * zoomcalibrator),
"#2J:-" + str(309 * zoomcalibrator),
"#1J:-" + str(475 * ZOOMCALIBRATOR),
"#2J:-" + str(309 * ZOOMCALIBRATOR),
),
(
(638, 392),
"#1J:-" + str(638 * zoomcalibrator),
"#2J:-" + str(392 * zoomcalibrator),
"#1J:-" + str(638 * ZOOMCALIBRATOR),
"#2J:-" + str(392 * ZOOMCALIBRATOR),
),
],
)
@patch(
"mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_moveonclick._get_beam_centre"
)
@patch(
"mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_moveonclick._get_beam_centre"
"mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_moveonclick._calculate_zoom_calibrator"
)
def test_onMouse_gets_beam_position_and_sends_correct_str(
fake_zoom_calibrator: MagicMock,
Expand All @@ -50,10 +49,10 @@ def test_onMouse_gets_beam_position_and_sends_correct_str(
pmac: PMAC,
RE,
):
fake_zoom_calibrator.return_value = zoomcalibrator
fake_zoom_calibrator.side_effect = [ZOOMCALIBRATOR]
fake_get_beam_pos.side_effect = [beam_position]
fake_oav: OAV = MagicMock(spec=OAV)
RE(onMouse(cv.EVENT_LBUTTONUP, 0, 0, "", param=[pmac, fake_oav]))
onMouse(cv.EVENT_LBUTTONUP, 0, 0, "", param=[RE, pmac, fake_oav])
mock_pmac_str = get_mock_put(pmac.pmac_string)
mock_pmac_str.assert_has_calls(
[
Expand Down

0 comments on commit 80442d1

Please sign in to comment.