diff --git a/src/fastcs_eiger/io.py b/src/fastcs_eiger/io.py index b4173a0..30168f8 100644 --- a/src/fastcs_eiger/io.py +++ b/src/fastcs_eiger/io.py @@ -79,4 +79,8 @@ async def update(self, attr: AttrR[DType_T, EigerParameterRef]) -> None: topic=attr, ) + # Some values are initially `null` in api + if value is None: + value = attr.datatype.initial_value + await attr.update(value) diff --git a/tests/test_io.py b/tests/test_io.py new file mode 100644 index 0000000..d7b4f2b --- /dev/null +++ b/tests/test_io.py @@ -0,0 +1,21 @@ +import pytest +from pytest_mock import MockerFixture + +from fastcs_eiger.io import EigerAttributeIO + + +@pytest.mark.asyncio +async def test_update(mocker: MockerFixture): + connection_mock = mocker.AsyncMock() + io = EigerAttributeIO(connection_mock, mocker.MagicMock(), mocker.MagicMock()) + attr = mocker.AsyncMock() + + connection_mock.get.return_value = {"value": 1} + await io.update(attr) + + attr.update.assert_called_once_with(1) + + connection_mock.get.return_value = {"value": None} + await io.update(attr) + + attr.update.assert_called_with(attr.datatype.initial_value)