Skip to content

Allow set_mock_value on derived signals #1132

@jacob720

Description

@jacob720

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_value on a derived signal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions