mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2026-02-05 06:38:41 +01:00
test: add test for epicsmotorvme
This commit is contained in:
@@ -163,15 +163,37 @@ def test_epics_motor_high_limit_switch_raises(mock_epics_motor):
|
|||||||
motor.move(15)
|
motor.move(15)
|
||||||
|
|
||||||
|
|
||||||
def test_epics_vme_user_motor():
|
@pytest.fixture(scope="function")
|
||||||
|
def motor():
|
||||||
|
with patched_device(EpicsUserMotorVME, _mock_pv_initial_value=2, name="motor") as mtr:
|
||||||
|
yield mtr
|
||||||
|
|
||||||
|
|
||||||
|
def test_epics_vme_user_motor(motor: EpicsUserMotorVME):
|
||||||
"""Test extended VME based user motor implementation EpicsUserMotors."""
|
"""Test extended VME based user motor implementation EpicsUserMotors."""
|
||||||
with mock.patch.object(ophyd, "cl") as mock_cl:
|
|
||||||
mock_cl.get_pv = MockPV
|
motor._ioc_enable._read_pv.mock_data = "Disable"
|
||||||
mock_cl.thread_class = threading.Thread
|
# Should enable the motor
|
||||||
device = EpicsUserMotorVME(name="test_motor_ex", prefix="SIM:MOTOR:EX")
|
motor.wait_for_connection(all_signals=True)
|
||||||
# Should raise
|
assert motor._ioc_enable.get() == "Enable"
|
||||||
with pytest.raises(RuntimeError):
|
|
||||||
device.wait_for_connection(all_signals=True)
|
# If high limit and low limit are both active, should raise error
|
||||||
# Should not raise
|
motor.high_limit_switch._read_pv.mock_data = 1
|
||||||
device._ioc_enable._read_pv.mock_data = "Enable"
|
motor.low_limit_switch._read_pv.mock_data = 1
|
||||||
device.wait_for_connection(all_signals=True)
|
with pytest.raises(RuntimeError):
|
||||||
|
motor.wait_for_connection(all_signals=True)
|
||||||
|
|
||||||
|
# Test subscription on _ioc_enable_changes
|
||||||
|
motor.device_manager = mock.MagicMock()
|
||||||
|
device_mock = mock.MagicMock()
|
||||||
|
|
||||||
|
class DeviceMock:
|
||||||
|
enabled = True
|
||||||
|
|
||||||
|
device_cls = DeviceMock()
|
||||||
|
motor.device_manager.devices = {motor.name: device_cls}
|
||||||
|
motor.on_connected()
|
||||||
|
|
||||||
|
# Change Enable to Disable
|
||||||
|
motor._ioc_enable.put("Disable")
|
||||||
|
assert device_cls.enabled is False
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from ophyd_devices.utils.psi_device_base_utils import (
|
|||||||
DeviceStatus,
|
DeviceStatus,
|
||||||
FileHandler,
|
FileHandler,
|
||||||
MoveStatus,
|
MoveStatus,
|
||||||
|
Status,
|
||||||
StatusBase,
|
StatusBase,
|
||||||
SubscriptionStatus,
|
SubscriptionStatus,
|
||||||
TaskHandler,
|
TaskHandler,
|
||||||
|
|||||||
Reference in New Issue
Block a user