-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Currently you can't set a mock value for derived signals using set_mock_value. For testing, it would make things easier if you could mock a derived signal without having to mock the underlying signals.
Currently, calling set_mock_value(my_derived_signal) causes RuntimeError: Cannot set the value of a derived signal, set the underlying raw signals instead.
From my experience, it also doesn't work to do something like
device._raw_to_derived = MagicMock(return_value=x)or
device.derived_signal.get_value = AsyncMock(return_value=x)This doesn't cause an error but doesn't give you the desired value when you read the derived signal.
What I found does work is doing
device.derived_signal.read = AsyncMock(
return_value={
"device-derived_signal": {
"value": x,
"timestamp": 1763051436.7372239,
"alarm_severity": 0,
}
}
)Acceptance Criteria
- You can call
set_mock_valueon a derived signal.
Metadata
Metadata
Assignees
Labels
No labels