1616 get_latest_daily ,
1717 get_field_measurements ,
1818 get_time_series_metadata ,
19+ get_reference_table
1920)
2021
2122def mock_request (requests_mock , request_url , file_path ):
@@ -139,11 +140,20 @@ def test_get_daily_properties():
139140 time = "2025-01-01/.." ,
140141 properties = ["daily_id" , "monitoring_location_id" , "parameter_code" , "time" , "value" , "geometry" ]
141142 )
142- assert "daily_id" in df .columns
143- assert "geometry" in df .columns
143+ assert "daily_id" == df .columns [ 0 ]
144+ assert "geometry" == df .columns [ - 1 ]
144145 assert df .shape [1 ] == 6
145146 assert df .parameter_code .unique ().tolist () == ["00060" ]
146147
148+ def test_get_daily_properties_id ():
149+ df ,_ = get_daily (
150+ monitoring_location_id = "USGS-05427718" ,
151+ parameter_code = "00060" ,
152+ time = "2025-01-01/.." ,
153+ properties = ["monitoring_location_id" , "id" , "parameter_code" , "time" , "value" , "geometry" ]
154+ )
155+ assert "daily_id" == df .columns [1 ]
156+
147157def test_get_daily_no_geometry ():
148158 df ,_ = get_daily (
149159 monitoring_location_id = "USGS-05427718" ,
@@ -187,7 +197,7 @@ def test_get_latest_continuous():
187197 monitoring_location_id = ["USGS-05427718" , "USGS-05427719" ],
188198 parameter_code = ["00060" , "00065" ]
189199 )
190- assert "latest_continuous_id" in df .columns
200+ assert "latest_continuous_id" == df .columns [ - 1 ]
191201 assert df .shape [0 ] <= 4
192202 assert df .statistic_id .unique ().tolist () == ["00011" ]
193203 assert hasattr (md , 'url' )
@@ -204,6 +214,15 @@ def test_get_latest_daily():
204214 assert hasattr (md , 'url' )
205215 assert hasattr (md , 'query_time' )
206216
217+ def test_get_latest_daily_properties_geometry ():
218+ df , md = get_latest_daily (
219+ monitoring_location_id = ["USGS-05427718" , "USGS-05427719" ],
220+ parameter_code = ["00060" , "00065" ],
221+ properties = ['monitoring_location_id' , 'parameter_code' , 'time' , 'value' , 'unit_of_measure' ]
222+ )
223+ assert "geometry" in df .columns
224+ assert df .shape [1 ] == 6
225+
207226def test_get_field_measurements ():
208227 df , md = get_field_measurements (
209228 monitoring_location_id = "USGS-05427718" ,
@@ -227,4 +246,14 @@ def test_get_time_series_metadata():
227246 assert hasattr (md , 'url' )
228247 assert hasattr (md , 'query_time' )
229248
249+ def test_get_reference_table ():
250+ df , md = get_reference_table ("agency-codes" )
251+ assert "agency_code_id" in df .columns
252+ assert df .shape [0 ] > 0
253+ assert hasattr (md , 'url' )
254+ assert hasattr (md , 'query_time' )
255+
256+ def test_get_reference_table_wrong_name ():
257+ with pytest .raises (ValueError ):
258+ get_reference_table ("agency-cod" )
230259
0 commit comments