Skip to content

Commit e51020b

Browse files
committed
usgs: Update tests
For some reason, USGS started to return additional data and as a result our tests are broken Not sure what exactly changed. Anyhow, this commit will let CI become green again. References #86
1 parent 861d274 commit e51020b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/usgs_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_get_usgs_stations():
7474
stations = usgs.get_usgs_stations()
7575
assert isinstance(stations, pd.DataFrame)
7676
assert isinstance(stations, gpd.GeoDataFrame)
77-
assert 40000 > len(stations) > 35000
77+
assert 40000 > len(stations) > 30000
7878
# check that the DataFrame has the right columns
7979
assert set(stations.columns).issuperset(usgs.USGS_STATIONS_COLUMN_NAMES)
8080
# Check that the parsing of the dates has been done correctly
@@ -90,8 +90,8 @@ def test_usgs_metadata_has_state_info():
9090
@pytest.mark.parametrize(
9191
"truncate_seconds,no_records",
9292
[
93-
pytest.param(True, 11, id="truncate_seconds=True"),
94-
pytest.param(False, 11, id="truncate_seconds=False"),
93+
pytest.param(True, 18, id="truncate_seconds=True"),
94+
pytest.param(False, 18, id="truncate_seconds=False"),
9595
],
9696
)
9797
def test_get_usgs_station_data(truncate_seconds, no_records):
@@ -142,7 +142,7 @@ def test_get_usgs_data(truncate_seconds):
142142
)
143143
assert isinstance(ds, xr.Dataset)
144144
# TODO: Check if truncate_seconds does work
145-
assert len(ds.datetime) == 222
145+
assert len(ds.datetime) == 226
146146
assert len(ds.site_no) == len(usgs_metadata)
147147
# Check that usgs_code, lon, lat, country and location are not modified
148148
assert set(ds.site_no.values).issubset(usgs_metadata.site_no.values)
@@ -151,8 +151,9 @@ def test_get_usgs_data(truncate_seconds):
151151
# assert set(ds.country.values).issubset(usgs_metadata.country.values)
152152
# assert set(ds.location.values).issubset(usgs_metadata.location.values)
153153
# Check that actual data has been retrieved
154-
assert ds.sel(site_no="15056500", code="72330").value.mean() == pytest.approx(109.94, rel=1e-3)
155-
assert ds.sel(site_no="15484000", code="72330").value.mean() == pytest.approx(637.84, rel=1e-3)
154+
code = "00065"
155+
assert ds.sel(site_no="15056500", code=code).value.mean() == pytest.approx(125.30, rel=1e-3)
156+
assert ds.sel(site_no="15484000", code=code).value.mean() == pytest.approx(323.24, rel=1e-3)
156157

157158

158159
def test_get_usgs_station_data_by_string_enddate():
@@ -163,7 +164,7 @@ def test_get_usgs_station_data_by_string_enddate():
163164
truncate_seconds=False,
164165
)
165166

166-
assert len(df) == 17
167+
assert len(df) == 30
167168

168169
dates = pd.to_datetime(df.index.get_level_values("datetime").to_series().dt.date.unique())
169170
assert len(dates) == 4

0 commit comments

Comments
 (0)