Skip to content

Commit b09fbd2

Browse files
thodson-usgsclaude
andcommitted
Add tripwire: every named waterdata replacement must exist
Addresses Copilot review on #271: `_REPLACEMENTS` points `get_discharge_peaks` -> `waterdata.get_peaks()` and `get_ratings` -> `waterdata.get_ratings()`. If this PR merged before its dependencies landed, users following the migration guidance would hit AttributeError. Adds a parametrized test that imports `dataretrieval.waterdata` and asserts every concrete callable named in the deprecation messages exists. The test currently fails on `get_peaks` (still on PR #267, not yet on main) — exactly the desired behavior: this PR cannot merge before #267. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f9f0e4f commit b09fbd2

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/nwis_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,33 @@ def test_nested_calls_emit_one_warning(self, requests_mock):
178178
assert len(deprecations) == 1
179179
assert "get_record" in str(deprecations[0].message)
180180

181+
@pytest.mark.parametrize(
182+
"name",
183+
[
184+
"get_daily",
185+
"get_continuous",
186+
"get_monitoring_locations",
187+
"get_stats_por",
188+
"get_stats_date_range",
189+
"get_peaks",
190+
"get_ratings",
191+
],
192+
)
193+
def test_named_replacement_exists_in_waterdata(self, name):
194+
"""Tripwire: every concrete `waterdata.*` named in a deprecation message
195+
must actually exist, so a user following the migration guidance doesn't
196+
hit AttributeError.
197+
198+
Fails loudly if this PR ever lands before its referenced replacement
199+
does (e.g. before `get_peaks` from #267).
200+
"""
201+
import dataretrieval.waterdata as wd
202+
203+
assert callable(getattr(wd, name, None)), (
204+
f"`waterdata.{name}` is missing — fix `_REPLACEMENTS` in nwis.py "
205+
"or add the replacement before merging."
206+
)
207+
181208

182209
class TestDefunct:
183210
"""Verify that defunct functions raise NameError."""

0 commit comments

Comments
 (0)