Files
seismo-relay/tests/test_minimate_download_replay.py
T
serversdownandClaude Opus 5.5 36f4e5d985 feat(sfm): a MiniMate download is checked against the unit's own peaks before it is stored
Series 4 downloads were checked (decoded PVS against the unit's); Series 3's
were stored unchecked (verified=None), so BE9441's two bad files went in as
successes at the bench (2026-10-25).  verify_s3_download(): if the waveform
decodes, all three geophone channels must be the same length and each peak must
be the unit's own 0C peak to one 0.005 in/s step, or the download is refused
(MalformedReply, "not saved").  Unverified (stored, as before): no waveform
decode -- a histogram; 0 of ~430 fixture histograms decode as one -- or a
sensitive-range unit, whose scale is still open.  The reason goes in
detail["check"].

A test puts the metadata-page bug back and the check refuses the file it
produced.  Session-replay helpers move to tests/minimate_replay.py.

No codec, store or DB change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
2026-10-25 18:14:44 -04:00

45 lines
1.6 KiB
Python

"""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)