fix: cleanup, add test for ddg base class

This commit is contained in:
2024-12-05 08:51:31 +01:00
parent 13f456e78e
commit 7fe80c1608
6 changed files with 176 additions and 796 deletions

View File

@@ -2,16 +2,29 @@ from unittest import mock
def patch_dual_pvs(device):
"""Patch dual PVs"""
patch_functions_required_for_connection(device)
device.wait_for_connection(all_signals=True)
for walk in device.walk_signals():
if not hasattr(walk.item, "_read_pv"):
continue
if not hasattr(walk.item, "_write_pv"):
continue
if walk.item._read_pv.pvname.endswith("_RBV"):
if walk.item._read_pv.pvname != walk.item._write_pv.pvname:
walk.item._read_pv = walk.item._write_pv
def patch_functions_required_for_connection(device):
"""Patch functions required for connection. This will run the subs for all sub devices and devices.
This is needed to ensure that the wait_for_connection method of required for connections methods are properly patched.
"""
for event in device.event_types:
device._run_subs(sub_type=event, value=0, timestamp=0)
for name, dev in device.walk_subdevices(include_lazy=True):
for event in dev.event_types:
dev._run_subs(sub_type=event, value=0, timestamp=0)
class SocketMock:
"""Socket Mock. Used for testing"""