v1
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""End-to-end test through the real wmbusmeters binary (skipped if absent)."""
|
||||
|
||||
import asyncio
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from oms_tui.wmbus import WMBusSource
|
||||
|
||||
TELEGRAM = (
|
||||
"C1;1;1;2020-01-23 10:25:13.000;97;148;76348799;"
|
||||
"0x2A442D2C998734761B168D2091D37CAC21E1D68CDAFFCD3DC452BD802913FF7B1706CA9E355D6C2701CC24\n"
|
||||
)
|
||||
KEY = "28F64A24988064A079AA2C807D6102AE"
|
||||
|
||||
|
||||
@pytest.mark.skipif(shutil.which("wmbusmeters") is None, reason="wmbusmeters not on PATH")
|
||||
def test_pipeline_discovers_and_decrypts():
|
||||
events = []
|
||||
|
||||
async def run():
|
||||
src = WMBusSource(
|
||||
device="stdin:rtlwmbus", stdin_data=(TELEGRAM * 3).encode()
|
||||
)
|
||||
src.set_keys({"76348799": KEY})
|
||||
await src.start(events.append)
|
||||
for _ in range(50): # up to ~5s for the process to finish replaying
|
||||
await asyncio.sleep(0.1)
|
||||
if any(e["type"] == "json" for e in events):
|
||||
break
|
||||
await src.stop()
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
ids = {e.get("id") for e in events if e["type"] in ("dll", "json")}
|
||||
assert "76348799" in ids
|
||||
|
||||
dlls = [e for e in events if e["type"] == "dll"]
|
||||
assert any(e["manufacturer"] == "KAM" for e in dlls)
|
||||
|
||||
jsons = [e for e in events if e["type"] == "json"]
|
||||
assert jsons, "no decrypted telegram produced"
|
||||
assert any(e["fields"].get("total_m3") == 6.408 for e in jsons)
|
||||
Reference in New Issue
Block a user