Skip to content

Commit

Permalink
TST: include Readback in test_client.py::test_apply
Browse files Browse the repository at this point in the history
The test didn't consider Readback handling because sample_database doesn't
include any Readbacks. Rather than modify sample_database and possibly
affect other tests, I've added a minimal fixture for considering a single
Setpoint-Readback pair.
  • Loading branch information
shilorigins committed Aug 2, 2024
1 parent 54737d0 commit e372952
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 21 additions & 0 deletions superscore/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,27 @@ def parameter_with_readback() -> Parameter:
return setpoint


@pytest.fixture(scope='function')
def setpoint_with_readback() -> Setpoint:
"""
A simple setpoint-readback value pair
"""
readback = Readback(
uuid="7b30ddba-9fae-4691-988c-07384c29fe22",
pv_name="RBV",
description="A readback PV",
data=False,
)
setpoint = Setpoint(
uuid="418ed1ab-f1cf-4188-8f4c-ae7cbaf00e6c",
pv_name="SET",
description="A setpoint PV",
data=True,
readback=readback,
)
return setpoint


@pytest.fixture(scope='function')
def filestore_backend(tmp_path: Path) -> FilestoreBackend:
fp = Path(__file__).parent / 'db' / 'filestore.json'
Expand Down
6 changes: 5 additions & 1 deletion superscore/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_gather_data(mock_client, sample_database):


@patch('superscore.control_layers.core.ControlLayer.put')
def test_apply(put_mock, mock_client: Client, sample_database: Root):
def test_apply(put_mock, mock_client: Client, sample_database: Root, setpoint_with_readback):
put_mock.return_value = MockTaskStatus()
snap = sample_database.entries[3]
mock_client.apply(snap)
Expand All @@ -69,6 +69,10 @@ def test_apply(put_mock, mock_client: Client, sample_database: Root):
mock_client.apply(snap, sequential=True)
assert put_mock.call_count == 3

put_mock.reset_mock()
mock_client.apply(setpoint_with_readback, sequential=True)
assert put_mock.call_count == 1


@patch('superscore.control_layers.core.ControlLayer._get_one')
def test_snap(
Expand Down

0 comments on commit e372952

Please sign in to comment.