Skip to content

Commit

Permalink
TST: add simple snapshot RO-parameter -> Readback test
Browse files Browse the repository at this point in the history
  • Loading branch information
tangkong committed Sep 3, 2024
1 parent 70d7035 commit c61fe06
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion superscore/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from superscore.client import Client
from superscore.control_layers import EpicsData
from superscore.errors import CommunicationError
from superscore.model import Parameter, Readback, Root, Setpoint
from superscore.model import Collection, Parameter, Readback, Root, Setpoint

from .conftest import MockTaskStatus

Expand Down Expand Up @@ -104,6 +104,26 @@ def test_snap_exception(get_mock, mock_client: Client, sample_database: Root):
assert snapshot.children[2].data is None


@patch('superscore.control_layers.core.ControlLayer._get_one')
def test_snap_RO(get_mock, mock_client: Client, sample_database: Root):
coll: Collection = sample_database.entries[2]
coll.children.append(
Parameter(pv_name="RO:PV",
abs_tolerance=1,
rel_tolerance=-.1,
read_only=True)
)
get_mock.side_effect = [EpicsData(i) for i in range(5)]
snapshot = mock_client.snap(coll)

assert get_mock.call_count == 4
for coll_child, snap_child in zip(coll.children, snapshot.children):
if coll_child.read_only:
assert isinstance(snap_child, Readback)
else:
assert isinstance(snap_child, Setpoint)


def test_from_cfg(sscore_cfg: str):
client = Client.from_config()
assert isinstance(client.backend, FilestoreBackend)
Expand Down

0 comments on commit c61fe06

Please sign in to comment.