Skip to content

Commit

Permalink
check for new columns
Browse files Browse the repository at this point in the history
  • Loading branch information
jarq6c authored and aaraney committed May 19, 2023
1 parent 64ea1d7 commit ff98895
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion python/nwis_client/tests/test_nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_get_value_time(setup_iv_value_time, sites, validation):
def test_get_with_expanded_metadata(setup_iv):
"""Test expanded metadata option"""
df = setup_iv.get(sites=["01646500"], parameterCd="00060", include_expanded_metadata=True)
assert (df["hucCd"] == "02070008").all()
assert (df["huc_code"] == "02070008").all()

def test_get_raw_with_mock(setup_iv, monkeypatch):
"""Test data retrieval and parsing"""
Expand Down Expand Up @@ -227,6 +227,34 @@ def requests_mock(*args, **kwargs):
data = setup_iv.get_raw(sites="01646500", parameterCd="00060,00065", include_expanded_metadata=True)
assert data[0]["hucCd"] == "02070008"

def test_expanded_metadata_columns(setup_iv, monkeypatch):
"""Test data retrieval and parsing"""
import json
from pathlib import Path
from hydrotools._restclient import RestClient

def requests_mock(*args, **kwargs):
json_text = json.loads(
(Path(__file__).resolve().parent / "nwis_test_data.json").read_text()
)
# key_word_args = {"_json": json_text}
return MockRequests(_json=json_text)

monkeypatch.setattr(RestClient, "get", requests_mock)

data = setup_iv.get(sites="01646500", parameterCd="00060,00065", include_expanded_metadata=True)
extra_columns = [
"site_type_code",
"huc_code",
"county_code",
"state_code",
"site_name",
"latitude",
"longitude"
]
for c in extra_columns:
assert c in data.columns


def test_handle_response(setup_iv, monkeypatch):
import json
Expand Down

0 comments on commit ff98895

Please sign in to comment.