Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/nwis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_set_metadata_info_countyCd(self, httpx_mock):


class TestReadRdb:
"""Tests for the NWIS-specific _read_rdb wrapper.
"""Tests for the NWIS-specific parse-then-format path.

The format-agnostic parser is exercised in tests/rdb_test.py; this
class pins the wrapper-specific contract — that an empty parser
Expand Down Expand Up @@ -374,6 +374,17 @@ def test_no_peaks_flows_through_format_response(self):
assert isinstance(df, pd.DataFrame)
assert df.empty

def test_malformed_peaks_frame_still_raises(self):
"""Only an *empty* peaks frame is a legitimate empty result. A
non-empty frame with no ``peak_dt`` column is a malformed response --
a truncated or altered RDB header -- and must stay loud rather than be
returned silently without its datetime index.
"""
df = pd.DataFrame({"peak_va": [1000]})

with pytest.raises(KeyError, match="peak_dt"):
format_response(df, service="peaks")


class TestGetRecordDispatch:
"""``get_record`` is a router; each service must reach its own getter.
Expand Down