Update tests/test_utils_opmsg.py
Run CI Tests / test (push) Successful in 1m28s

This commit is contained in:
2025-08-08 15:01:45 +02:00
parent 780f2f2add
commit 4abf793815
+13 -9
View File
@@ -10,7 +10,6 @@ import time
import threading
import pytest
from morbidissimo import MorIOC
from slic.utils.opmsg import IDS, BEAMLINES, N_MSG_HISTORY
def ioc():
"""
@@ -25,8 +24,8 @@ def ioc():
mor.host(
STATUS={"type": "enum", "enums": ["OFFLINE", "PREPARATION", "REMOTE", "ATTENDED"]},
**{"STATUS-DATE": str},
**{f"OP-DATE{i}": str for i in range(N_MSG_HISTORY)},
**{f"OP-MSG{i}": str for i in range(N_MSG_HISTORY)},
**{f"OP-DATE{i}": str for i in range(3)},
**{f"OP-MSG{i}": str for i in range(3)},
**{"OP-MSG-TMP": str},
)
@@ -34,8 +33,8 @@ def ioc():
mor.serve(
STATUS="OFFLINE",
**{"STATUS-DATE": "2024-01-01 00:00:00"},
**{f"OP-DATE{i}": f"2024-01-01 00:00:0{i}" for i in range(N_MSG_HISTORY)},
**{f"OP-MSG{i}": f"Initial message {i}" for i in range(N_MSG_HISTORY)},
**{f"OP-DATE{i}": f"2024-01-01 00:00:0{i}" for i in range(3)},
**{f"OP-MSG{i}": f"Initial message {i}" for i in range(3)},
**{"OP-MSG-TMP": ""},
)
@@ -71,7 +70,7 @@ def ioc():
@pytest.fixture(scope="module", autouse=True)
def run_all_iocs():
threads = ioc()
time.sleep(0.5)
time.sleep(3.0)
yield
@@ -289,9 +288,14 @@ class TestOperationMessages:
def test_iter_yields_operationmessage_instances(self):
oms = OperationMessages()
vals = list(iter(oms))
assert len(vals) == len(IDS)
assert all(isinstance(v, OperationMessage) for v in vals)
for om in oms:
_reset_operation_message_to_defaults(om)
for om in oms:
assert om.status.status == "OFFLINE"
for i, entry in enumerate(om.entries):
assert entry.date == f"2024-01-01 00:00:{i}"
assert entry.msg == f"Initial message {i}"
# All prefixes serve identical initial data; verify contents quickly
for om in vals: