Files
2026-10-07 10:38:21 +02:00

33 lines
1.0 KiB
Python

"""End-to-end pipeline tests against opc.fake (IMPLEMENTATION_PLAN §9).
The fake client lets the event pipeline run without COM/hardware; Phase 1
grows this into the full scenario suite.
"""
import pytest
from opcda_diagnozer.opc.base import OpcError
from opcda_diagnozer.opc.fake import FakeOpcClient
def test_fake_reads_good_quality() -> None:
client = FakeOpcClient()
client.connect()
results = client.read(["Channel1.Device1.Counter", "Channel1.Device1.Level"])
assert [r.tag for r in results] == ["Channel1.Device1.Counter", "Channel1.Device1.Level"]
assert all(r.quality_raw == 0xC0 for r in results)
assert all(r.device_time is not None for r in results)
def test_fake_requires_connect_first() -> None:
client = FakeOpcClient()
with pytest.raises(OpcError):
client.read(["Channel1.Device1.Counter"])
def test_fake_close_disconnects() -> None:
client = FakeOpcClient()
client.connect()
client.close()
with pytest.raises(OpcError):
client.read(["Channel1.Device1.Counter"])