Skip to content

Commit bd15fb7

Browse files
committed
pva tests
1 parent 8b61772 commit bd15fb7

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tests/update_handlers/pva_update_handler_test.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
)
1717
from streaming_data_types.logdata_f142 import deserialise_f142
1818
from streaming_data_types.logdata_f144 import deserialise_f144
19+
from streaming_data_types.units_un00 import deserialise_un00
1920
from streaming_data_types.timestamps_tdct import deserialise_tdct
2021
from streaming_data_types.utils import get_schema
2122

@@ -86,6 +87,11 @@ def test_update_handler_publishes_enum_update_f144(context, producer, pv_source_
8687
pv_update_output = deserialise_f144(producer.published_payloads[-3])
8788
assert np.allclose(pv_update_output.value, pv_index)
8889
assert pv_update_output.source_name == pv_source_name
90+
# EGU does not exist on an enum so make sure we havent sent a unit update
91+
un00_messages = [
92+
msg for msg in producer.published_payloads if "un00" == get_schema(msg)
93+
]
94+
assert len(un00_messages) == 0
8995

9096

9197
@pytest.mark.schema("f142")
@@ -463,12 +469,22 @@ def test_handler_does_not_publish_if_never_connected(
463469

464470
assert len(producer.published_payloads) == 0
465471

472+
@pytest.mark.schema("f144")
473+
def test_handler_publishes_update_with_changed_unit(context, producer, pv_source_name):
474+
expected_unit = 'mm'
475+
t = NTScalar("i", valueAlarm=True, display=True, control=True).wrap(123, timestamp=time(), )
476+
t.display.units = expected_unit
477+
478+
context.call_monitor_callback_with_fake_pv_update(t)
479+
assert len(producer.published_payloads) == 4
480+
assert deserialise_un00(producer.published_payloads[-1]).units == expected_unit
466481

467-
def test_handler_does_not_publish_unit_update_if_egu_does_not_exist():
468-
pass
482+
@pytest.mark.schema("f144")
483+
def test_handler_publishes_blank_update_initially(context, producer, pv_source_name):
484+
t = NTScalar("i", valueAlarm=True, display=True, control=True).wrap(123, timestamp=time(), )
485+
assert t.display.units == ''
469486

470-
def test_handler_publishes_update_with_changed_unit():
471-
pass
487+
context.call_monitor_callback_with_fake_pv_update(t)
488+
assert len(producer.published_payloads) == 4
489+
assert deserialise_un00(producer.published_payloads[-1]).units == ''
472490

473-
def test_handler_publishes_blank_update_initially():
474-
pass

0 commit comments

Comments
 (0)