|
16 | 16 | ) |
17 | 17 | from streaming_data_types.logdata_f142 import deserialise_f142 |
18 | 18 | from streaming_data_types.logdata_f144 import deserialise_f144 |
| 19 | +from streaming_data_types.units_un00 import deserialise_un00 |
19 | 20 | from streaming_data_types.timestamps_tdct import deserialise_tdct |
20 | 21 | from streaming_data_types.utils import get_schema |
21 | 22 |
|
@@ -86,6 +87,11 @@ def test_update_handler_publishes_enum_update_f144(context, producer, pv_source_ |
86 | 87 | pv_update_output = deserialise_f144(producer.published_payloads[-3]) |
87 | 88 | assert np.allclose(pv_update_output.value, pv_index) |
88 | 89 | 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 |
89 | 95 |
|
90 | 96 |
|
91 | 97 | @pytest.mark.schema("f142") |
@@ -463,12 +469,22 @@ def test_handler_does_not_publish_if_never_connected( |
463 | 469 |
|
464 | 470 | assert len(producer.published_payloads) == 0 |
465 | 471 |
|
| 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 |
466 | 481 |
|
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 == '' |
469 | 486 |
|
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 == '' |
472 | 490 |
|
473 | | -def test_handler_publishes_blank_update_initially(): |
474 | | - pass |
|
0 commit comments