diff --git a/tests/data/nwis_site_seriescatalog.txt b/tests/data/nwis_site_seriescatalog.txt deleted file mode 100644 index 149048bd..00000000 --- a/tests/data/nwis_site_seriescatalog.txt +++ /dev/null @@ -1,46 +0,0 @@ -# -# -# US Geological Survey -# retrieved: 2026-06-24 13:30:23 -04:00 (caas01) -# -# The Site File stores location and general information about groundwater, -# surface water, and meteorological sites -# for sites in USA. -# -# File-format description: http://help.waterdata.usgs.gov/faq/about-tab-delimited-output -# Automated-retrieval info: http://waterservices.usgs.gov/rest/Site-Service.html -# -# Contact: gs-w_support_nwisweb@usgs.gov -# -# The following selected fields are included in this output: -# -# agency_cd -- Agency -# site_no -- Site identification number -# station_nm -- Site name -# site_tp_cd -- Site type -# dec_lat_va -- Decimal latitude -# dec_long_va -- Decimal longitude -# coord_acy_cd -- Latitude-longitude accuracy -# dec_coord_datum_cd -- Decimal Latitude-longitude datum -# alt_va -- Altitude of Gage/land surface -# alt_acy_va -- Altitude accuracy -# alt_datum_cd -- Altitude datum -# huc_cd -- Hydrologic unit code -# data_type_cd -- Data type -# parm_cd -- Parameter code -# stat_cd -- Statistical code -# ts_id -- Internal timeseries ID -# loc_web_ds -- Additional measurement description -# medium_grp_cd -- Medium group code -# parm_grp_cd -- Parameter group code -# srs_id -- SRS ID -# access_cd -- Access code -# begin_date -- Begin date -# end_date -- End date -# count_nu -- Record count -# -agency_cd site_no station_nm site_tp_cd dec_lat_va dec_long_va coord_acy_cd dec_coord_datum_cd alt_va alt_acy_va alt_datum_cd huc_cd data_type_cd parm_cd stat_cd ts_id loc_web_ds medium_grp_cd parm_grp_cd srs_id access_cd begin_date end_date count_nu -5s 15s 50s 7s 16s 16s 1s 10s 8s 3s 10s 16s 2s 5s 5s 5n 30s 3s 3s 5n 4n 20d 20d 5n -USGS 01491000 CHOPTANK RIVER NEAR GREENSBORO, MD ST 38.99719444 -75.7858056 S NAD83 2.73 .1 NAVD88 02060005 ad 0 wat 0 0 2006 2025 20 -USGS 01491000 CHOPTANK RIVER NEAR GREENSBORO, MD ST 38.99719444 -75.7858056 S NAD83 2.73 .1 NAVD88 02060005 dv 00010 00001 68074 [Discontinued] wat 1645597 0 1988-10-01 2012-05-09 894 -USGS 01491000 CHOPTANK RIVER NEAR GREENSBORO, MD ST 38.99719444 -75.7858056 S NAD83 2.73 .1 NAVD88 02060005 dv 00010 00001 327630 wat 1645597 0 2023-04-21 2026-06-23 1155 diff --git a/tests/nwis_test.py b/tests/nwis_test.py index 42ff8606..905ed8db 100644 --- a/tests/nwis_test.py +++ b/tests/nwis_test.py @@ -1,4 +1,3 @@ -import datetime import json import re import warnings @@ -14,14 +13,12 @@ _read_rdb, get_discharge_measurements, get_gwlevels, - get_info, get_iv, get_pmcodes, get_qwdata, get_record, get_water_use, preformat_peaks_response, - what_sites, ) START_DATE = "2018-01-24" @@ -30,9 +27,8 @@ DATETIME_COL = "datetime" SITENO_COL = "site_no" -# Legacy NWIS endpoints these tests mock — this module makes no live calls. +# Legacy NWIS site endpoint these tests mock — this module makes no live calls. _SITE_RE = re.compile(r"^https://waterservices\.usgs\.gov/nwis/site(\?.*)?$") -_IV_RE = re.compile(r"^https://waterservices\.usgs\.gov/nwis/iv(\?.*)?$") def _load_mock_json(file_name): @@ -223,86 +219,6 @@ def test_get_record_defunct_service_water_use(self): get_record(service="water_use") -class TestTZ: - """Tests relating to GitHub Issue #60 — merging IV results across sites - yields a proper datetime index. Mocked against fixture responses.""" - - def _mock(self, httpx_mock): - _mock_site(httpx_mock) - httpx_mock.add_response( - method="GET", url=_IV_RE, json=_load_mock_json("nwis_iv_mock.json") - ) - - def test_multiple_tz_01(self, httpx_mock): - """Issue #60 - merging IV across sites yields a datetime index.""" - self._mock(httpx_mock) - sites, _ = what_sites(stateCd="MD") - iv, _ = get_iv(sites=sites.site_no.values[:25].tolist()) - assert "datetime" in iv.index.names - assert isinstance(iv.index[0][1], datetime.datetime) - - def test_multiple_tz_02(self, httpx_mock): - """Issue #60 - the same-tz path also yields a datetime index.""" - self._mock(httpx_mock) - sites, _ = what_sites(stateCd="MD") - iv, _ = get_iv(sites=sites.site_no.values[:20].tolist()) - assert "datetime" in iv.index.names - assert isinstance(iv.index[0][1], datetime.datetime) - - -class TestSiteseriesCatalogOutput: - """Tests relating to GitHub Issue #34 — ``seriesCatalogOutput`` adds the - data-inventory columns (begin_date / end_date / count_nu). Mocked against - fixture responses (the chosen fixture, not the request param, decides which - columns come back).""" - - _SERIESCATALOG = "nwis_site_seriescatalog.txt" - - def test_seriesCatalogOutput_get_record(self, httpx_mock): - """seriesCatalogOutput=True with get_record exposes inventory columns.""" - _mock_site(httpx_mock, self._SERIESCATALOG) - data = get_record( - huc="20", parameterCd="00060", service="site", seriesCatalogOutput="True" - ) - assert "begin_date" in data.columns - assert "end_date" in data.columns - assert "count_nu" in data.columns - - def test_seriesCatalogOutput_get_info(self, httpx_mock): - """seriesCatalogOutput=TRUE with get_info exposes inventory columns.""" - _mock_site(httpx_mock, self._SERIESCATALOG) - data, _ = get_info(huc="20", parameterCd="00060", seriesCatalogOutput="TRUE") - assert "begin_date" in data.columns - assert "end_date" in data.columns - assert "count_nu" in data.columns - - def test_seriesCatalogOutput_bool(self, httpx_mock): - """A boolean seriesCatalogOutput is accepted and exposes inventory cols.""" - _mock_site(httpx_mock, self._SERIESCATALOG) - data, _ = get_info(huc="20", parameterCd="00060", seriesCatalogOutput=True) - assert "begin_date" in data.columns - assert "end_date" in data.columns - assert "count_nu" in data.columns - - def test_expandedrdb_get_record(self, httpx_mock): - """The default expanded-rdb format omits the inventory columns.""" - _mock_site(httpx_mock) - data = get_record( - huc="20", parameterCd="00060", service="site", seriesCatalogOutput="False" - ) - assert "begin_date" not in data.columns - assert "end_date" not in data.columns - assert "count_nu" not in data.columns - - def test_expandedrdb_get_info(self, httpx_mock): - """get_info default omits the inventory columns.""" - _mock_site(httpx_mock) - data, _ = get_info(huc="20", parameterCd="00060") - assert "begin_date" not in data.columns - assert "end_date" not in data.columns - assert "count_nu" not in data.columns - - def test_empty_timeseries(httpx_mock): """Test based on empty case from GitHub Issue #26.""" sites = "011277906" diff --git a/tests/waterdata_filters_test.py b/tests/waterdata_filters_test.py index b87ec272..6d5f9310 100644 --- a/tests/waterdata_filters_test.py +++ b/tests/waterdata_filters_test.py @@ -41,22 +41,6 @@ def test_quote_cql_str_doubles_embedded_quotes(): assert _quote_cql_str("a'b'c") == "a''b''c" -def test_construct_filter_passthrough(): - """`filter` is forwarded verbatim as a query parameter.""" - expr = ( - "(time >= '2023-01-06T16:00:00Z' AND time <= '2023-01-06T18:00:00Z') " - "OR (time >= '2023-01-10T18:00:00Z' AND time <= '2023-01-10T20:00:00Z')" - ) - req = _construct_api_requests( - service="continuous", - monitoring_location_id="USGS-07374525", - parameter_code="72255", - filter=expr, - ) - qs = _query_params(req) - assert qs["filter"] == [expr] - - def test_construct_filter_lang_hyphenated(): """The Python kwarg `filter_lang` is sent as URL key `filter-lang`.""" req = _construct_api_requests(