The reference for the Series 3 decode checker: scalars and value units, channels, the job number, the user notes in order under their operator-edited labels, waveform rows as printed (ragged where channels end at different lengths) and histogram intervals. Seven real DL2 events as fixtures, each covering a case the comparison must handle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
"""
|
|
Blastware's `_XML.XML` event report, parsed (decode checker, Task 1).
|
|
|
|
Expected values are copied from the fixture XML files themselves.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from minimateplus.bw_xml_report import parse_xml_report, parse_xml_report_file
|
|
|
|
FIX = Path(__file__).parent / "fixtures/decode-checker-10-29-26"
|
|
|
|
|
|
def test_scalars_units_and_special_text():
|
|
r = parse_xml_report_file(FIX / "T1905KDW_5F0W_XML.XML")
|
|
assert r.scalars["SampleRate"] == "1024 sps"
|
|
assert r.scalars["RecordTime"] == "1.0 sec."
|
|
assert r.scalars["TranPPV"] == "0.005" and r.units["TranPPV"] == "in/s"
|
|
assert r.scalars["VertZCFreq"] == ">100" # entity unescaped
|
|
assert r.scalars["TranZCFreq"] == "N/A"
|
|
assert r.scalars["TranTestResults"] == "Check"
|
|
assert r.scalars["BatteryLevel"] == "6.7 Volts"
|
|
assert r.job_number == "1" and r.notes == []
|
|
assert r.channels == ["Tran", "Vert", "Long", "MicL"]
|
|
|
|
|
|
def test_waveform_sample_rows():
|
|
r = parse_xml_report_file(FIX / "T1905KDW_5F0W_XML.XML")
|
|
assert len(r.sample_rows) == 1024
|
|
assert r.sample_rows[0] == ["-0.005", "0.000", "0.000", "81.94"]
|
|
assert r.intervals is None
|
|
|
|
|
|
def test_ragged_rows_are_kept_as_printed():
|
|
r = parse_xml_report_file(FIX / "T438HGTZ_B30W_XML.XML")
|
|
assert len(r.sample_rows) == 2304
|
|
assert r.sample_rows[-4] == ["-0.185", "0.235", "-0.255", "-87.96"]
|
|
assert r.sample_rows[-1] == ["-0.245"] # only Long still running
|
|
|
|
|
|
def test_relabelled_notes_keep_their_tags_in_order():
|
|
r = parse_xml_report_file(FIX / "M529L4XQ_R30H_XML.XML")
|
|
assert r.notes == [("Location", "Test Loc")]
|
|
r = parse_xml_report_file(FIX / "T004JTRF_ME0H_XML.XML")
|
|
assert r.notes[1] == ("Client", "Mele & Mele & Sons, Inc.")
|
|
assert r.event_units == "in/s and psi(L)"
|
|
|
|
|
|
def test_notes_and_job_number_are_not_scalars():
|
|
r = parse_xml_report_file(FIX / "T004JTRF_ME0H_XML.XML")
|
|
assert "Project" not in r.scalars and "SeisLoc" not in r.scalars
|
|
r = parse_xml_report_file(FIX / "T1905KDW_5F0W_XML.XML")
|
|
assert "JobNumber" not in r.scalars
|
|
|
|
|
|
def test_histogram_intervals_and_columns():
|
|
r = parse_xml_report_file(FIX / "M529L4XQ_R30H_XML.XML")
|
|
assert r.interval_columns[0] == "Tran Peak in/s" and len(r.interval_columns) == 10
|
|
assert r.intervals == [("2025-07-02 14:55:08",
|
|
["2.430", "13", "0.940", ">100", "1.900", "5.8", "3.095", "0.001", "106.0", "51"])]
|
|
assert r.sample_rows is None
|
|
|
|
|
|
def test_no_mic_histogram_has_seven_columns():
|
|
r = parse_xml_report_file(FIX / "R352HFZ7_530H_XML.XML")
|
|
assert r.event_units == "in/s"
|
|
assert r.channels == ["Tran", "Vert", "Long"]
|
|
assert len(r.interval_columns) == 7 and len(r.intervals[0][1]) == 7
|
|
|
|
|
|
def test_oorange_and_range_values():
|
|
r = parse_xml_report_file(FIX / "M007HVWF_K30W_XML.XML")
|
|
assert r.scalars["TranPPV"] == "OORANGE"
|
|
assert r.scalars["GeoRange"] == "1.250" and r.units["GeoRange"] == "in/s"
|
|
|
|
|
|
def test_truncated_xml_raises_valueerror():
|
|
data = (FIX / "M529L4XQ_R30H_XML.XML").read_bytes()
|
|
with pytest.raises(ValueError):
|
|
parse_xml_report(data[: len(data) // 2])
|