bec_widgets.tests.utils#

Attributes#

Classes#

DMMock

Device

just placeholder for testing embedded isinstance check in DeviceCombobox

FakeDevice

Fake minimal positioner class for testing.

FakePositioner

Positioner:

Positioner

just placeholder for testing embedded isinstance check in DeviceCombobox

Functions#

check_remote_data_size(widget, plot_name, num_elements)

Check if the remote data has the correct number of elements.

Module Contents#

class DMMock(*args, **kwargs)#
_get_redis_device_config() list[dict]#

Mock method to emulate DeviceManager._get_redis_device_config.

add_devices(devices: list)#

Add devices to the DeviceContainer.

Parameters:

devices (list) – List of device instances to add.

get_bec_signals(signal_class_name: str)#

Emulate DeviceManager.get_bec_signals for unit-tests.

For “AsyncSignal” we list every device whose readout_priority is ReadoutPriority.ASYNC and build a minimal tuple (device_name, signal_name, signal_info_dict) that matches the real API shape used by Waveform._check_async_signal_found.

initialize()#
shutdown()#
config_helper#
devices#
enabled_devices#
class Device(name, enabled=True)#

Bases: FakeDevice

just placeholder for testing embedded isinstance check in DeviceCombobox

Parameters:
  • name (str) – The name of the device.

  • info (dict, optional) – The device info dictionary. Defaults to None.

  • parent ([type], optional) – The parent object. Defaults to None.

  • signal_info (dict, optional) – The signal info dictionary. Defaults to None.

  • class_name (str, optional) – The class name of the device. Defaults to None. If None, the class name is inferred from the class of the object.

class FakeDevice(name, enabled=True, readout_priority=ReadoutPriority.MONITORED)#

Bases: bec_lib.device.Device

Fake minimal positioner class for testing.

Parameters:
  • name (str) – The name of the device.

  • info (dict, optional) – The device info dictionary. Defaults to None.

  • parent ([type], optional) – The parent object. Defaults to None.

  • signal_info (dict, optional) – The signal info dictionary. Defaults to None.

  • class_name (str, optional) – The class name of the device. Defaults to None. If None, the class name is inferred from the class of the object.

__contains__(item)#
describe() dict#

Get the description of the device :returns: Description of the device :rtype: dict

set_value(fake_value: float = 1.0) None#

Setup fake value for device readout :param fake_value: Desired fake value :type fake_value: float

property _hints#
description#
property limits: tuple[float, float]#
property readout_priority#

get the readout priority for this device

signals#
class FakePositioner(name, enabled=True, limits=None, read_value=1.0, readout_priority=ReadoutPriority.MONITORED)#

Bases: bec_lib.device.Positioner

Positioner: * trigger * read * set * stop * settle_time * timeout * egu * limits * low_limit * high_limit * move * position * moving

Parameters:
  • name (str) – The name of the device.

  • info (dict, optional) – The device info dictionary. Defaults to None.

  • parent ([type], optional) – The parent object. Defaults to None.

  • signal_info (dict, optional) – The signal info dictionary. Defaults to None.

  • class_name (str, optional) – The class name of the device. Defaults to None. If None, the class name is inferred from the class of the object.

__contains__(item)#
describe() dict#

Get the description of the device :returns: Description of the device :rtype: dict

move(value, relative=False)#

Simulates moving the device to a new position.

read(cached=False)#

Reads the device.

Parameters:
  • cached (bool, optional) – If True, the cached value is returned. Defaults to False.

  • use_readback (bool, optional) – If True, the readback value is returned, otherwise the read value. Defaults to True.

  • filter_to_hints (bool, optional) – If True, the readback value is filtered to the hinted values. Defaults to False.

Returns:

The device signals.

Return type:

dict

set_limits(limits)#
set_read_value(value)#
set_value(fake_value: float = 1.0) None#

Setup fake value for device readout :param fake_value: Desired fake value :type fake_value: float

property _hints#
description#
property enabled: bool#

Returns True if the device is enabled, otherwise False.

property limits: tuple[float, float]#

Returns the device limits.

motor_is_moving_value = 0#
property precision#
read_value = 1.0#
property readback#
property readout_priority#

get the readout priority for this device

setpoint_value = 1.0#
signals#
class Positioner(name='test', limits=None, read_value=1.0, enabled=True)#

Bases: FakePositioner

just placeholder for testing embedded isinstance check in DeviceCombobox

Parameters:
  • name (str) – The name of the device.

  • info (dict, optional) – The device info dictionary. Defaults to None.

  • parent ([type], optional) – The parent object. Defaults to None.

  • signal_info (dict, optional) – The signal info dictionary. Defaults to None.

  • class_name (str, optional) – The class name of the device. Defaults to None. If None, the class name is inferred from the class of the object.

check_remote_data_size(widget, plot_name, num_elements)#

Check if the remote data has the correct number of elements. Used in the qtbot.waitUntil function.

DEVICES#