Skip to content

Commit 3515562

Browse files
thodson-usgsclaude
andcommitted
Cover the limit + query branch with no-mutation assertion
Per copilot review on PR #248. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1b613b0 commit 3515562

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/waterdata_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,36 @@ def test_get_reference_table_propagates_limit(requests_mock):
349349
assert "agency_code" in df.columns
350350

351351

352+
def test_get_reference_table_limit_with_query_does_not_mutate(requests_mock):
353+
"""`limit` is merged with a caller-supplied `query` dict without mutating it."""
354+
request_url = (
355+
"https://api.waterdata.usgs.gov/ogcapi/v0/collections/agency-codes/items"
356+
)
357+
body = {
358+
"type": "FeatureCollection",
359+
"features": [
360+
{
361+
"type": "Feature",
362+
"id": "USGS",
363+
"properties": {"agency_code": "USGS"},
364+
"geometry": None,
365+
}
366+
],
367+
"numberReturned": 1,
368+
"links": [],
369+
}
370+
requests_mock.get(request_url, json=body, headers={"mock_header": "value"})
371+
372+
user_query = {"id": "USGS"}
373+
user_query_snapshot = dict(user_query)
374+
get_reference_table("agency-codes", limit=42, query=user_query)
375+
376+
sent = requests_mock.request_history[-1]
377+
assert sent.qs.get("limit") == ["42"]
378+
assert sent.qs.get("id") == ["usgs"]
379+
assert user_query == user_query_snapshot
380+
381+
352382
def test_get_stats_por():
353383
df, _ = get_stats_por(
354384
monitoring_location_id="USGS-12451000",

0 commit comments

Comments
 (0)