Skip to content

Commit

Permalink
fix all tests with matching capital enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
jennmald committed Nov 22, 2024
1 parent 904f7dd commit f20cf4b
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion system_tests/epics/eiger/test_eiger_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def test_trigger_saves_file(test_eiger: EigerDetector, setup_device: Setup
single_shot = EigerTriggerInfo(
frame_timeout=None,
number_of_triggers=1,
trigger=DetectorTrigger.internal,
trigger=DetectorTrigger.INTERNAL,
deadtime=None,
livetime=None,
energy_ev=10000,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def one_shot_trigger_info() -> TriggerInfo:
return TriggerInfo(
frame_timeout=None,
number_of_triggers=1,
trigger=DetectorTrigger.internal,
trigger=DetectorTrigger.INTERNAL,
deadtime=None,
livetime=None,
)
Expand Down
38 changes: 19 additions & 19 deletions tests/core/test_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@


class TriggerState(StrictEnum):
null = "null"
preparing = "preparing"
starting = "starting"
stopping = "stopping"
NULL = "null"
PREPARING = "preparing"
STARTING = "starting"
STOPPING = "stopping"


class DummyTriggerLogic(FlyerController[int]):
def __init__(self):
self.state = TriggerState.null
self.state = TriggerState.NULL

async def prepare(self, value: int):
self.state = TriggerState.preparing
self.state = TriggerState.PREPARING
return value

async def kickoff(self):
self.state = TriggerState.starting
self.state = TriggerState.STARTING

async def complete(self):
self.state = TriggerState.null
self.state = TriggerState.NULL

async def stop(self):
self.state = TriggerState.stopping
self.state = TriggerState.STOPPING


class DummyWriter(DetectorWriter):
Expand Down Expand Up @@ -160,7 +160,7 @@ def append_and_print(name, doc):

def flying_plan():
yield from bps.stage_all(*detectors, flyer)
assert flyer._trigger_logic.state == TriggerState.stopping
assert flyer._trigger_logic.state == TriggerState.STOPPING

# move the flyer to the correct place, before fly scanning.
# Prepare the flyer first to get the trigger info for the detectors
Expand All @@ -172,14 +172,14 @@ def flying_plan():
detector,
TriggerInfo(
number_of_triggers=number_of_triggers,
trigger=DetectorTrigger.constant_gate,
trigger=DetectorTrigger.CONSTANT_GATE,
deadtime=2,
livetime=2,
),
wait=True,
)

assert flyer._trigger_logic.state == TriggerState.preparing
assert flyer._trigger_logic.state == TriggerState.PREPARING
for detector in detectors:
detector.controller.disarm.assert_called_once() # type: ignore

Expand All @@ -195,7 +195,7 @@ def flying_plan():
for detector in detectors:
yield from bps.complete(detector, wait=False, group="complete")

assert flyer._trigger_logic.state == TriggerState.null
assert flyer._trigger_logic.state == TriggerState.NULL

# Manually increment the index as if a frame was taken
frames_completed += frames
Expand Down Expand Up @@ -227,7 +227,7 @@ def flying_plan():
yield from bps.unstage_all(flyer, *detectors)
for detector in detectors:
assert detector.controller.disarm.called # type: ignore
assert trigger_logic.state == TriggerState.stopping
assert trigger_logic.state == TriggerState.STOPPING

# fly scan
RE(flying_plan())
Expand Down Expand Up @@ -282,14 +282,14 @@ async def test_hardware_triggered_flyable_too_many_kickoffs(
flyer = StandardFlyer(trigger_logic, name="flyer")
trigger_info = TriggerInfo(
number_of_triggers=number_of_triggers,
trigger=DetectorTrigger.constant_gate,
trigger=DetectorTrigger.CONSTANT_GATE,
deadtime=2,
livetime=2,
)

def flying_plan():
yield from bps.stage_all(*detectors, flyer)
assert flyer._trigger_logic.state == TriggerState.stopping
assert flyer._trigger_logic.state == TriggerState.STOPPING

# move the flyer to the correct place, before fly scanning.
# Prepare the flyer first to get the trigger info for the detectors
Expand All @@ -316,7 +316,7 @@ def flying_plan():
for detector in detectors:
yield from bps.complete(detector, wait=False, group="complete")

assert flyer._trigger_logic.state == TriggerState.null
assert flyer._trigger_logic.state == TriggerState.NULL

# Manually increment the index as if a frame was taken
for detector in detectors:
Expand Down Expand Up @@ -367,7 +367,7 @@ def flying_plan():
(
{
"number_of_triggers": 1,
"trigger": DetectorTrigger.constant_gate,
"trigger": DetectorTrigger.CONSTANT_GATE,
"deadtime": 2,
"livetime": 2,
"frame_timeout": "a",
Expand All @@ -388,7 +388,7 @@ def flying_plan():
(
{
"number_of_triggers": 1,
"trigger": DetectorTrigger.internal,
"trigger": DetectorTrigger.INTERNAL,
"deadtime": 2,
"livetime": 1,
"frame_timeout": -1,
Expand Down
14 changes: 7 additions & 7 deletions tests/core/test_soft_signal_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@


class MyEnum(StrictEnum):
a = "Aaa"
b = "Bbb"
c = "Ccc"
A = "Aaa"
B = "Bbb"
C = "Ccc"


def integer_d(value):
Expand Down Expand Up @@ -80,7 +80,7 @@ def close(self):
(int, 0, 43, integer_d, default_int_type),
(float, 0.0, 43.5, number_d, "<f8"),
(str, "", "goodbye", string_d, "|S40"),
(MyEnum, MyEnum.a, MyEnum.c, enum_d, "|S40"),
(MyEnum, MyEnum.A, MyEnum.C, enum_d, "|S40"),
(Array1D[np.int8], [], [-8, 3, 44], waveform_d, "|i1"),
(Array1D[np.uint8], [], [218], waveform_d, "|u1"),
(Array1D[np.int16], [], [-855], waveform_d, "<i2"),
Expand Down Expand Up @@ -126,9 +126,9 @@ async def test_soft_signal_backend_get_put_monitor(
async def test_soft_signal_backend_enum_value_equivalence():
soft_backend = SoftSignalBackend(MyEnum)
await soft_backend.connect(timeout=1)
assert (await soft_backend.get_value()) is MyEnum.a
await soft_backend.put(MyEnum.b, True)
assert (await soft_backend.get_value()) is MyEnum.b
assert (await soft_backend.get_value()) is MyEnum.A
await soft_backend.put(MyEnum.B, True)
assert (await soft_backend.get_value()) is MyEnum.B


async def test_soft_signal_backend_with_numpy_typing():
Expand Down
12 changes: 6 additions & 6 deletions tests/core/test_subset_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@


class AB(SubsetEnum):
a = "A"
b = "B"
A = "A"
B = "B"


class AB1(SubsetEnum):
a = "A1"
b = "B1"
A = "A1"
B = "B1"


class AB2(SubsetEnum):
a = "A2"
b = "B2"
A = "A2"
B = "B2"


async def test_ca_runtime_enum_converter():
Expand Down
4 changes: 2 additions & 2 deletions tests/epics/adaravis/test_aravis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def trigger_and_complete():
await test_adaravis.controller.prepare(
TriggerInfo(
number_of_triggers=1,
trigger=DetectorTrigger.edge_trigger,
trigger=DetectorTrigger.EDGE_TRIGGER,
livetime=None,
deadtime=None,
frame_timeout=None,
Expand Down Expand Up @@ -154,7 +154,7 @@ async def test_unsupported_trigger_excepts(test_adaravis: adaravis.AravisDetecto
await test_adaravis.prepare(
TriggerInfo(
number_of_triggers=0,
trigger=DetectorTrigger.variable_gate,
trigger=DetectorTrigger.VARIABLE_GATE,
deadtime=1,
livetime=1,
frame_timeout=3,
Expand Down
6 changes: 3 additions & 3 deletions tests/epics/adcore/test_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def test_set_exposure_time_and_acquire_period_if_supplied_uses_deadtime(
async def test_start_acquiring_driver_and_ensure_status_flags_immediate_failure(
driver: adcore.ADBaseIO,
):
set_mock_value(driver.detector_state, adcore.DetectorState.Error)
set_mock_value(driver.detector_state, adcore.DetectorState.ERROR)
acquiring = await adcore.start_acquiring_driver_and_ensure_status(
driver, timeout=0.01
)
Expand All @@ -84,11 +84,11 @@ async def test_start_acquiring_driver_and_ensure_status_fails_after_some_time(
Real world application; it takes some time to start acquiring, and during that time
the detector gets itself into a bad state.
"""
set_mock_value(driver.detector_state, adcore.DetectorState.Idle)
set_mock_value(driver.detector_state, adcore.DetectorState.IDLE)

async def wait_then_fail():
await asyncio.sleep(0)
set_mock_value(driver.detector_state, adcore.DetectorState.Disconnected)
set_mock_value(driver.detector_state, adcore.DetectorState.DISCONNECTED)

acquiring = await adcore.start_acquiring_driver_and_ensure_status(
driver, timeout=0.1
Expand Down
2 changes: 1 addition & 1 deletion tests/epics/adcore/test_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_hdf_writer_fails_on_timeout_with_flyscan(
flyer = StandardFlyer(trigger_logic, name="flyer")
trigger_info = TriggerInfo(
number_of_triggers=1,
trigger=DetectorTrigger.constant_gate,
trigger=DetectorTrigger.CONSTANT_GATE,
deadtime=2,
livetime=2,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/epics/adcore/test_single_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def plan():
yield from bps.abs_set(single_trigger_det.drv.acquire_time, 0.5)
yield from bps.abs_set(single_trigger_det.drv.array_counter, 1)
yield from bps.abs_set(
single_trigger_det.drv.image_mode, adcore.ImageMode.continuous
single_trigger_det.drv.image_mode, adcore.ImageMode.CONTINUOUS
)
# set_mock_value(stats.unique_id, 3)
yield from bp.count([single_trigger_det])
Expand All @@ -42,7 +42,7 @@ def plan():

drv = single_trigger_det.drv
assert 1 == await drv.acquire.get_value()
assert adcore.ImageMode.single == await drv.image_mode.get_value()
assert adcore.ImageMode.SINGLE == await drv.image_mode.get_value()
assert True is await drv.wait_for_plugins.get_value()

assert names == ["start", "descriptor", "event", "stop"]
Expand Down
10 changes: 5 additions & 5 deletions tests/epics/adkinetix/test_kinetix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def test_get_deadtime(

async def test_trigger_modes(test_adkinetix: adkinetix.KinetixDetector):
set_mock_value(
test_adkinetix.drv.trigger_mode, adkinetix.KinetixTriggerMode.internal
test_adkinetix.drv.trigger_mode, adkinetix.KinetixTriggerMode.INTERNAL
)

async def setup_trigger_mode(trig_mode: DetectorTrigger):
Expand All @@ -38,16 +38,16 @@ async def setup_trigger_mode(trig_mode: DetectorTrigger):
# Default TriggerSource
assert (await test_adkinetix.drv.trigger_mode.get_value()) == "Internal"

await setup_trigger_mode(DetectorTrigger.edge_trigger)
await setup_trigger_mode(DetectorTrigger.EDGE_TRIGGER)
assert (await test_adkinetix.drv.trigger_mode.get_value()) == "Rising Edge"

await setup_trigger_mode(DetectorTrigger.constant_gate)
await setup_trigger_mode(DetectorTrigger.CONSTANT_GATE)
assert (await test_adkinetix.drv.trigger_mode.get_value()) == "Exp. Gate"

await setup_trigger_mode(DetectorTrigger.internal)
await setup_trigger_mode(DetectorTrigger.INTERNAL)
assert (await test_adkinetix.drv.trigger_mode.get_value()) == "Internal"

await setup_trigger_mode(DetectorTrigger.variable_gate)
await setup_trigger_mode(DetectorTrigger.VARIABLE_GATE)
assert (await test_adkinetix.drv.trigger_mode.get_value()) == "Exp. Gate"


Expand Down
24 changes: 12 additions & 12 deletions tests/epics/adpilatus/test_pilatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_adpilatus(ad_standard_det_factory) -> adpilatus.PilatusDetector:

async def test_deadtime_overridable(test_adpilatus: adpilatus.PilatusDetector):
pilatus_controller = test_adpilatus._controller
pilatus_controller._readout_time = adpilatus.PilatusReadoutTime.pilatus2
pilatus_controller._readout_time = adpilatus.PilatusReadoutTime.PILATUS2

# deadtime invariant with exposure time
assert pilatus_controller.get_deadtime(0) == 2.28e-3
Expand All @@ -37,9 +37,9 @@ async def test_deadtime_invariant(
@pytest.mark.parametrize(
"detector_trigger,expected_trigger_mode",
[
(DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal),
(DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal),
(DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal),
(DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL),
(DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL),
(DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL),
],
)
async def test_trigger_mode_set(
Expand All @@ -63,7 +63,7 @@ async def test_trigger_mode_set_without_armed_pv(
):
async def trigger_and_complete():
await test_adpilatus.controller.prepare(
TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.internal)
TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.INTERNAL)
)
await test_adpilatus.controller.arm()
await test_adpilatus.controller.wait_for_idle()
Expand All @@ -75,7 +75,7 @@ async def trigger_and_complete():
with pytest.raises(asyncio.TimeoutError):
await _trigger(
test_adpilatus,
adpilatus.PilatusTriggerMode.internal,
adpilatus.PilatusTriggerMode.INTERNAL,
trigger_and_complete,
)

Expand All @@ -88,7 +88,7 @@ async def _trigger(
# Default TriggerMode
assert (
await test_adpilatus.drv.trigger_mode.get_value()
) == adpilatus.PilatusTriggerMode.internal
) == adpilatus.PilatusTriggerMode.INTERNAL

await trigger_and_complete()

Expand All @@ -109,7 +109,7 @@ async def test_unsupported_trigger_excepts(test_adpilatus: adpilatus.PilatusDete
await test_adpilatus.prepare(
TriggerInfo(
number_of_triggers=1,
trigger=DetectorTrigger.edge_trigger,
trigger=DetectorTrigger.EDGE_TRIGGER,
deadtime=1.0,
livetime=1.0,
)
Expand All @@ -127,7 +127,7 @@ async def dummy_open(multiplier: int = 0):
await test_adpilatus.prepare(
TriggerInfo(
number_of_triggers=1,
trigger=DetectorTrigger.internal,
trigger=DetectorTrigger.INTERNAL,
deadtime=1.0,
livetime=1.0,
)
Expand All @@ -141,16 +141,16 @@ async def test_pilatus_controller(test_adpilatus: adpilatus.PilatusDetector):
pilatus_driver = pilatus._drv
set_mock_value(pilatus_driver.armed, True)
await pilatus.prepare(
TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.constant_gate)
TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.CONSTANT_GATE)
)
await pilatus.arm()
await pilatus.wait_for_idle()

assert await pilatus_driver.num_images.get_value() == 1
assert await pilatus_driver.image_mode.get_value() == adcore.ImageMode.multiple
assert await pilatus_driver.image_mode.get_value() == adcore.ImageMode.MULTIPLE
assert (
await pilatus_driver.trigger_mode.get_value()
== adpilatus.PilatusTriggerMode.ext_enable
== adpilatus.PilatusTriggerMode.EXT_ENABLE
)
assert await pilatus_driver.acquire.get_value() is True

Expand Down
Loading

0 comments on commit f20cf4b

Please sign in to comment.