File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
352382def test_get_stats_por ():
353383 df , _ = get_stats_por (
354384 monitoring_location_id = "USGS-12451000" ,
You can’t perform that action at this time.
0 commit comments