|
6 | 6 |
|
7 | 7 | import matplotlib.pyplot as plt |
8 | 8 | import pytest |
9 | | -from bluesky import RunEngine, plan_stubs as bps |
| 9 | +from bluesky import RunEngine |
| 10 | +from bluesky import plan_stubs as bps |
10 | 11 | from bluesky.utils import Msg |
11 | 12 | from ophyd_async.epics.motor import UseSetMode |
12 | 13 | from ophyd_async.plan_stubs import ensure_connected |
13 | 14 | from ophyd_async.testing import get_mock_put, set_mock_value |
14 | 15 |
|
15 | 16 | from ibex_bluesky_core.devices import NoYesChoice, compress_and_hex, dehex_and_decompress |
16 | 17 | from ibex_bluesky_core.devices.block import BlockMot |
17 | | -from ibex_bluesky_core.devices.dae import Dae, TCBCalculationMethod, TCBTimeUnit, DaeTCBSettingsData, DaeSettingsData |
| 18 | +from ibex_bluesky_core.devices.dae import ( |
| 19 | + Dae, |
| 20 | + DaeSettingsData, |
| 21 | + DaeTCBSettingsData, |
| 22 | + TCBCalculationMethod, |
| 23 | + TCBTimeUnit, |
| 24 | +) |
18 | 25 | from ibex_bluesky_core.devices.dae._tcb_settings import _convert_xml_to_tcb_settings |
19 | 26 | from ibex_bluesky_core.devices.reflectometry import ReflParameter |
20 | 27 | from ibex_bluesky_core.plan_stubs import ( |
|
29 | 36 | from ibex_bluesky_core.plan_stubs.num_periods_wrapper import with_num_periods |
30 | 37 | from ibex_bluesky_core.plan_stubs.time_channels_wrapper import with_time_channels |
31 | 38 | from ibex_bluesky_core.run_engine._msg_handlers import call_sync_handler |
32 | | -from tests.devices.dae_testing_data import tcb_settings_template, dae_settings_template |
| 39 | +from tests.devices.dae_testing_data import dae_settings_template, tcb_settings_template |
33 | 40 |
|
34 | 41 |
|
35 | 42 | def test_call_sync_returns_result(RE): |
@@ -210,15 +217,13 @@ def test_num_periods_wrapper(dae: Dae, RE: RunEngine): |
210 | 217 | assert mock_set_calls[1].args[0] == original_settings |
211 | 218 |
|
212 | 219 |
|
213 | | -async def test_time_channels_wrapper(dae: Dae, RE: RunEngine): |
| 220 | +def test_time_channels_wrapper(dae: Dae, RE: RunEngine): |
214 | 221 | expected_tcb_file = "C:\\tcb.dat" |
215 | 222 | expected_calc_method = TCBCalculationMethod.SPECIFY_PARAMETERS |
216 | 223 | expected_time_unit = TCBTimeUnit.MICROSECONDS |
217 | 224 |
|
218 | | - |
219 | 225 | modified_settings = DaeTCBSettingsData(time_unit=TCBTimeUnit.NANOSECONDS) |
220 | 226 |
|
221 | | - |
222 | 227 | original_tcb_settings = tcb_settings_template.format( |
223 | 228 | tcb_file=expected_tcb_file, |
224 | 229 | time_units=expected_time_unit.value, |
@@ -345,7 +350,6 @@ async def test_time_channels_wrapper(dae: Dae, RE: RunEngine): |
345 | 350 | tr6_steps_5=1, |
346 | 351 | ) |
347 | 352 |
|
348 | | - |
349 | 353 | modified_raw_tcb_settings = tcb_settings_template.format( |
350 | 354 | tcb_file=expected_tcb_file, |
351 | 355 | time_units=TCBTimeUnit.NANOSECONDS.value, |
@@ -472,27 +476,27 @@ async def test_time_channels_wrapper(dae: Dae, RE: RunEngine): |
472 | 476 | tr6_steps_5=1, |
473 | 477 | ) |
474 | 478 |
|
475 | | - set_mock_value(dae.tcb_settings._raw_tcb_settings, compress_and_hex(original_tcb_settings).decode()) |
| 479 | + set_mock_value( |
| 480 | + dae.tcb_settings._raw_tcb_settings, compress_and_hex(original_tcb_settings).decode() |
| 481 | + ) |
476 | 482 |
|
477 | 483 | with patch("ibex_bluesky_core.plan_stubs.time_channels_wrapper.ensure_connected"): |
478 | | - RE( |
479 | | - with_time_channels( |
480 | | - bps.null(), |
481 | | - dae=dae, |
482 | | - new_tcb_settings=modified_settings |
483 | | - ) |
484 | | - ) |
| 484 | + RE(with_time_channels(bps.null(), dae=dae, new_tcb_settings=modified_settings)) |
485 | 485 |
|
486 | 486 | mock_set_calls = get_mock_put(dae.tcb_settings._raw_tcb_settings).call_args_list |
487 | 487 |
|
488 | 488 | # Note for these two assertions that you can't compare XML directly as order isn't guaranteed, |
489 | 489 | # so convert to the dataclass instead. |
490 | 490 |
|
491 | 491 | # assert that modified settings are set |
492 | | - assert _convert_xml_to_tcb_settings(modified_raw_tcb_settings) == _convert_xml_to_tcb_settings(dehex_and_decompress(mock_set_calls[0].args[0]).decode()) |
| 492 | + assert _convert_xml_to_tcb_settings(modified_raw_tcb_settings) == _convert_xml_to_tcb_settings( |
| 493 | + dehex_and_decompress(mock_set_calls[0].args[0]).decode() |
| 494 | + ) |
493 | 495 |
|
494 | 496 | # assert that the original settings are restored |
495 | | - assert _convert_xml_to_tcb_settings(original_tcb_settings) == _convert_xml_to_tcb_settings(dehex_and_decompress(mock_set_calls[1].args[0]).decode()) |
| 497 | + assert _convert_xml_to_tcb_settings(original_tcb_settings) == _convert_xml_to_tcb_settings( |
| 498 | + dehex_and_decompress(mock_set_calls[1].args[0]).decode() |
| 499 | + ) |
496 | 500 |
|
497 | 501 |
|
498 | 502 | def test_dae_table_wrapper(dae: Dae, RE: RunEngine): |
@@ -553,13 +557,7 @@ def test_dae_table_wrapper(dae: Dae, RE: RunEngine): |
553 | 557 | set_mock_value(dae.dae_settings._raw_dae_settings, original_settings) |
554 | 558 |
|
555 | 559 | with patch("ibex_bluesky_core.plan_stubs.dae_table_wrapper.ensure_connected"): |
556 | | - RE( |
557 | | - with_dae_tables( |
558 | | - bps.null(), |
559 | | - dae=dae, |
560 | | - new_settings=modified_settings |
561 | | - ) |
562 | | - ) |
| 560 | + RE(with_dae_tables(bps.null(), dae=dae, new_settings=modified_settings)) |
563 | 561 |
|
564 | 562 | mock_set_calls = get_mock_put(dae.dae_settings._raw_dae_settings).call_args_list |
565 | 563 |
|
|
0 commit comments