|
2 | 2 | import pickle |
3 | 3 | from collections.abc import Mapping |
4 | 4 | from unittest import mock |
5 | | -from unittest.mock import MagicMock, Mock |
| 5 | +from unittest.mock import AsyncMock, MagicMock, Mock |
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 | from bluesky.plans import scan |
|
18 | 18 | ) |
19 | 19 |
|
20 | 20 | from dodal.devices.apple2_undulator import ( |
| 21 | + MAXIMUM_MOVE_TIME, |
21 | 22 | BeamEnergy, |
22 | 23 | EnabledDisabledUpper, |
23 | 24 | InsertionDeviceEnergy, |
@@ -303,6 +304,17 @@ async def test_fail_i10_apple2_controller_set_id_not_ready( |
303 | 304 | ) |
304 | 305 |
|
305 | 306 |
|
| 307 | +async def test_fail_i10_apple2_controller_set_energy_has_default( |
| 308 | + mock_id_energy: InsertionDeviceEnergy, |
| 309 | + mock_id_controller: I10Apple2Controller, |
| 310 | +): |
| 311 | + mock_id_controller.energy.set = AsyncMock() |
| 312 | + await mock_id_energy.set(600) |
| 313 | + mock_id_controller.energy.set.assert_awaited_once_with( |
| 314 | + 600, timeout=MAXIMUM_MOVE_TIME |
| 315 | + ) |
| 316 | + |
| 317 | + |
306 | 318 | async def test_beam_energy_re_scan( |
307 | 319 | run_engine: RunEngine, |
308 | 320 | run_engine_documents: Mapping[str, list[dict]], |
@@ -414,6 +426,18 @@ async def test_id_polarisation_set( |
414 | 426 | assert float(gap.call_args[0][0]) == pytest.approx(expect_gap, 0.05) |
415 | 427 |
|
416 | 428 |
|
| 429 | +async def test_id_polarisation_set_has_default_timeout( |
| 430 | + mock_id_pol: InsertionDevicePolarisation, |
| 431 | + mock_id_controller: I10Apple2Controller, |
| 432 | +): |
| 433 | + set_mock_value(mock_id_controller._energy, 700) |
| 434 | + mock_id_controller.polarisation.set = AsyncMock() |
| 435 | + await mock_id_pol.set(Pol.LV) |
| 436 | + mock_id_controller.polarisation.set.assert_awaited_once_with( |
| 437 | + Pol.LV, timeout=MAXIMUM_MOVE_TIME |
| 438 | + ) |
| 439 | + |
| 440 | + |
417 | 441 | @pytest.mark.parametrize( |
418 | 442 | "pol,energy, top_outer, top_inner, btm_inner,btm_outer", |
419 | 443 | [ |
@@ -551,6 +575,17 @@ async def test_linear_arbitrary_pol_fail_read( |
551 | 575 | ) |
552 | 576 |
|
553 | 577 |
|
| 578 | +async def test_linear_arbitrary_pol_set_default_timeout( |
| 579 | + mock_linear_arbitrary_angle: LinearArbitraryAngle, |
| 580 | + mock_id_controller: I10Apple2Controller, |
| 581 | +): |
| 582 | + mock_id_controller.linear_arbitrary_angle.set = AsyncMock() |
| 583 | + await mock_linear_arbitrary_angle.set(60) |
| 584 | + mock_id_controller.linear_arbitrary_angle.set.assert_awaited_once_with( |
| 585 | + 60, timeout=MAXIMUM_MOVE_TIME |
| 586 | + ) |
| 587 | + |
| 588 | + |
554 | 589 | @pytest.mark.parametrize( |
555 | 590 | "poly", |
556 | 591 | [18, -18, 12.01, -12.01], |
|
0 commit comments