"""BE9441's recorded one-event download, replayed through the real MiniMateClient. The bench session (2026-10-25) is replayed reply for reply: SESSION_RESET gets none, every other request the next recorded frame. Whole, it must give event 1 in full (the metadata-page fix); silenced partway through the 5A stream, as the unit was when it rebooted, it must raise (the strict-stream fix), never return a short event. """ from __future__ import annotations import os import sys import pytest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import minimateplus.client as mc # noqa: E402 import minimateplus.protocol as mp # noqa: E402 from minimate_replay import KEY, STAMP, SessionReplay, fast_clock, recorded_replies # noqa: E402 @pytest.fixture(autouse=True) def _fast(monkeypatch): fast_clock(monkeypatch) def download(quiet_5a_from=None): client = mc.MiniMateClient(transport=SessionReplay(recorded_replies(), quiet_5a_from)) client.open() client.connect() return client.download_event_by_key(KEY, expected_timestamp=STAMP) def test_the_whole_session_gives_event_1_in_full(): ev = download() assert {ch: len(ev.raw_samples[ch]) for ch in ("Tran", "Vert", "Long")} == \ {"Tran": 21_504, "Vert": 21_504, "Long": 21_504} def test_a_unit_that_goes_quiet_mid_stream_raises_instead_of_returning_a_short_event(): with pytest.raises(mp.ProtocolError, match="ended early"): download(quiet_5a_from=40)