Skip to content

Commit 7a831f3

Browse files
thodson-usgsclaude
andcommitted
test: prune tautological / redundant tests
Follow-up to DOI-USGS#334 (mocking the live NWIS tests). Once mocked, two NWIS classes became tautological — they assert the columns/shape of the fixture they feed, exercising no production logic the mocked-out parse doesn't already cover: - nwis_test.py: delete TestSiteseriesCatalogOutput (DOI-USGS#34 — RDB column parsing is covered by rdb_test.py + TestReadRdb, and the seriesCatalogOutput param is not exercised because the mock returns the fixture regardless) and TestTZ (DOI-USGS#60 — now identical to test_iv_service_answer: same fixture, same datetime-index assertion). Drop the orphaned nwis_site_seriescatalog.txt fixture and the now-unused imports. - waterdata_filters_test.py: delete test_construct_filter_passthrough — `filter` is forwarded verbatim, so it is subsumed by the parametrized test_construct_filter_on_all_ogc_services (8 services + filter-lang) and the long-filter fan-out tests. A 4-agent review of the full suite (17 files) found the rest well-curated; these are the only defensible deletions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sjb14HkwuCydKSKMsaXsgd
1 parent 8e10d23 commit 7a831f3

3 files changed

Lines changed: 1 addition & 147 deletions

File tree

tests/data/nwis_site_seriescatalog.txt

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/nwis_test.py

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import datetime
21
import json
32
import re
43
import warnings
@@ -14,14 +13,12 @@
1413
_read_rdb,
1514
get_discharge_measurements,
1615
get_gwlevels,
17-
get_info,
1816
get_iv,
1917
get_pmcodes,
2018
get_qwdata,
2119
get_record,
2220
get_water_use,
2321
preformat_peaks_response,
24-
what_sites,
2522
)
2623

2724
START_DATE = "2018-01-24"
@@ -30,9 +27,8 @@
3027
DATETIME_COL = "datetime"
3128
SITENO_COL = "site_no"
3229

33-
# Legacy NWIS endpoints these tests mock — this module makes no live calls.
30+
# Legacy NWIS site endpoint these tests mock — this module makes no live calls.
3431
_SITE_RE = re.compile(r"^https://waterservices\.usgs\.gov/nwis/site(\?.*)?$")
35-
_IV_RE = re.compile(r"^https://waterservices\.usgs\.gov/nwis/iv(\?.*)?$")
3632

3733

3834
def _load_mock_json(file_name):
@@ -223,86 +219,6 @@ def test_get_record_defunct_service_water_use(self):
223219
get_record(service="water_use")
224220

225221

226-
class TestTZ:
227-
"""Tests relating to GitHub Issue #60 — merging IV results across sites
228-
yields a proper datetime index. Mocked against fixture responses."""
229-
230-
def _mock(self, httpx_mock):
231-
_mock_site(httpx_mock)
232-
httpx_mock.add_response(
233-
method="GET", url=_IV_RE, json=_load_mock_json("nwis_iv_mock.json")
234-
)
235-
236-
def test_multiple_tz_01(self, httpx_mock):
237-
"""Issue #60 - merging IV across sites yields a datetime index."""
238-
self._mock(httpx_mock)
239-
sites, _ = what_sites(stateCd="MD")
240-
iv, _ = get_iv(sites=sites.site_no.values[:25].tolist())
241-
assert "datetime" in iv.index.names
242-
assert isinstance(iv.index[0][1], datetime.datetime)
243-
244-
def test_multiple_tz_02(self, httpx_mock):
245-
"""Issue #60 - the same-tz path also yields a datetime index."""
246-
self._mock(httpx_mock)
247-
sites, _ = what_sites(stateCd="MD")
248-
iv, _ = get_iv(sites=sites.site_no.values[:20].tolist())
249-
assert "datetime" in iv.index.names
250-
assert isinstance(iv.index[0][1], datetime.datetime)
251-
252-
253-
class TestSiteseriesCatalogOutput:
254-
"""Tests relating to GitHub Issue #34 — ``seriesCatalogOutput`` adds the
255-
data-inventory columns (begin_date / end_date / count_nu). Mocked against
256-
fixture responses (the chosen fixture, not the request param, decides which
257-
columns come back)."""
258-
259-
_SERIESCATALOG = "nwis_site_seriescatalog.txt"
260-
261-
def test_seriesCatalogOutput_get_record(self, httpx_mock):
262-
"""seriesCatalogOutput=True with get_record exposes inventory columns."""
263-
_mock_site(httpx_mock, self._SERIESCATALOG)
264-
data = get_record(
265-
huc="20", parameterCd="00060", service="site", seriesCatalogOutput="True"
266-
)
267-
assert "begin_date" in data.columns
268-
assert "end_date" in data.columns
269-
assert "count_nu" in data.columns
270-
271-
def test_seriesCatalogOutput_get_info(self, httpx_mock):
272-
"""seriesCatalogOutput=TRUE with get_info exposes inventory columns."""
273-
_mock_site(httpx_mock, self._SERIESCATALOG)
274-
data, _ = get_info(huc="20", parameterCd="00060", seriesCatalogOutput="TRUE")
275-
assert "begin_date" in data.columns
276-
assert "end_date" in data.columns
277-
assert "count_nu" in data.columns
278-
279-
def test_seriesCatalogOutput_bool(self, httpx_mock):
280-
"""A boolean seriesCatalogOutput is accepted and exposes inventory cols."""
281-
_mock_site(httpx_mock, self._SERIESCATALOG)
282-
data, _ = get_info(huc="20", parameterCd="00060", seriesCatalogOutput=True)
283-
assert "begin_date" in data.columns
284-
assert "end_date" in data.columns
285-
assert "count_nu" in data.columns
286-
287-
def test_expandedrdb_get_record(self, httpx_mock):
288-
"""The default expanded-rdb format omits the inventory columns."""
289-
_mock_site(httpx_mock)
290-
data = get_record(
291-
huc="20", parameterCd="00060", service="site", seriesCatalogOutput="False"
292-
)
293-
assert "begin_date" not in data.columns
294-
assert "end_date" not in data.columns
295-
assert "count_nu" not in data.columns
296-
297-
def test_expandedrdb_get_info(self, httpx_mock):
298-
"""get_info default omits the inventory columns."""
299-
_mock_site(httpx_mock)
300-
data, _ = get_info(huc="20", parameterCd="00060")
301-
assert "begin_date" not in data.columns
302-
assert "end_date" not in data.columns
303-
assert "count_nu" not in data.columns
304-
305-
306222
def test_empty_timeseries(httpx_mock):
307223
"""Test based on empty case from GitHub Issue #26."""
308224
sites = "011277906"

tests/waterdata_filters_test.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@ def test_quote_cql_str_doubles_embedded_quotes():
4141
assert _quote_cql_str("a'b'c") == "a''b''c"
4242

4343

44-
def test_construct_filter_passthrough():
45-
"""`filter` is forwarded verbatim as a query parameter."""
46-
expr = (
47-
"(time >= '2023-01-06T16:00:00Z' AND time <= '2023-01-06T18:00:00Z') "
48-
"OR (time >= '2023-01-10T18:00:00Z' AND time <= '2023-01-10T20:00:00Z')"
49-
)
50-
req = _construct_api_requests(
51-
service="continuous",
52-
monitoring_location_id="USGS-07374525",
53-
parameter_code="72255",
54-
filter=expr,
55-
)
56-
qs = _query_params(req)
57-
assert qs["filter"] == [expr]
58-
59-
6044
def test_construct_filter_lang_hyphenated():
6145
"""The Python kwarg `filter_lang` is sent as URL key `filter-lang`."""
6246
req = _construct_api_requests(

0 commit comments

Comments
 (0)