Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
thodson-usgs committed Sep 17, 2024
1 parent 91947ad commit ec36997
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions tests/wqp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
def test_get_results(requests_mock):
"""Tests water quality portal results query"""
request_url = "https://www.waterqualitydata.us/data/Result/Search?siteid=WIDNR_WQX-10032762" \
"&characteristicName=Specific+conductance&startDateLo=05-01-2011&startDateHi=09-30-2011" \
"&mimeType=csv"
"&characteristicName=Specific+conductance&startDateLo=05-01-2011&startDateHi=09-30-2011"
response_file_path = 'data/wqp_results.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = get_results(siteid='WIDNR_WQX-10032762',
Expand All @@ -39,7 +38,7 @@ def test_get_results_WQX3(requests_mock):
"""Tests water quality portal results query with new WQX3.0 profile"""
request_url = "https://www.waterqualitydata.us/wqx3/Result/search?siteid=WIDNR_WQX-10032762" \
"&characteristicName=Specific+conductance&startDateLo=05-01-2011&startDateHi=09-30-2011" \
"&mimeType=csv&dataProfile=fullPhysChem"
"&dataProfile=fullPhysChem"
response_file_path = 'data/wqp3_results.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = get_results(legacy=False, siteid='WIDNR_WQX-10032762',
Expand All @@ -55,8 +54,7 @@ def test_get_results_WQX3(requests_mock):

def test_what_sites(requests_mock):
"""Tests Water quality portal sites query"""
request_url = "https://www.waterqualitydata.us/data/Station/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/Station/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_sites.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_sites(statecode="US:34", characteristicName="Chloride")
Expand All @@ -70,8 +68,7 @@ def test_what_sites(requests_mock):

def test_what_organizations(requests_mock):
"""Tests Water quality portal organizations query"""
request_url = "https://www.waterqualitydata.us/data/Organization/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/Organization/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_organizations.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_organizations(statecode="US:34", characteristicName="Chloride")
Expand All @@ -85,8 +82,7 @@ def test_what_organizations(requests_mock):

def test_what_projects(requests_mock):
"""Tests Water quality portal projects query"""
request_url = "https://www.waterqualitydata.us/data/Project/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/Project/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_projects.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_projects(statecode="US:34", characteristicName="Chloride")
Expand All @@ -100,8 +96,7 @@ def test_what_projects(requests_mock):

def test_what_activities(requests_mock):
"""Tests Water quality portal activities query"""
request_url = "https://www.waterqualitydata.us/data/Activity/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/Activity/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_activities.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_activities(statecode="US:34", characteristicName="Chloride")
Expand All @@ -115,8 +110,7 @@ def test_what_activities(requests_mock):

def test_what_detection_limits(requests_mock):
"""Tests Water quality portal detection limits query"""
request_url = "https://www.waterqualitydata.us/data/ResultDetectionQuantitationLimit/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/ResultDetectionQuantitationLimit/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_detection_limits.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_detection_limits(statecode="US:34", characteristicName="Chloride")
Expand All @@ -130,8 +124,7 @@ def test_what_detection_limits(requests_mock):

def test_what_habitat_metrics(requests_mock):
"""Tests Water quality portal habitat metrics query"""
request_url = "https://www.waterqualitydata.us/data/BiologicalMetric/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/BiologicalMetric/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_habitat_metrics.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_habitat_metrics(statecode="US:34", characteristicName="Chloride")
Expand All @@ -145,8 +138,7 @@ def test_what_habitat_metrics(requests_mock):

def test_what_project_weights(requests_mock):
"""Tests Water quality portal project weights query"""
request_url = "https://www.waterqualitydata.us/data/ProjectMonitoringLocationWeighting/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/ProjectMonitoringLocationWeighting/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_project_weights.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_project_weights(statecode="US:34", characteristicName="Chloride")
Expand All @@ -160,8 +152,7 @@ def test_what_project_weights(requests_mock):

def test_what_activity_metrics(requests_mock):
"""Tests Water quality portal activity metrics query"""
request_url = "https://www.waterqualitydata.us/data/ActivityMetric/Search?statecode=US%3A34&characteristicName=Chloride" \
"&mimeType=csv"
request_url = "https://www.waterqualitydata.us/data/ActivityMetric/Search?statecode=US%3A34&characteristicName=Chloride"
response_file_path = 'data/wqp_activity_metrics.txt'
mock_request(requests_mock, request_url, response_file_path)
df, md = what_activity_metrics(statecode="US:34", characteristicName="Chloride")
Expand All @@ -178,7 +169,7 @@ def mock_request(requests_mock, request_url, file_path):
requests_mock.get(request_url, text=text.read(), headers={"mock_header": "value"})


def test_check_mimetype(self):
def test_check_mimetype():
"""Tests that correct errors are raised for invalid mimetypes."""
kwargs = {"mimeType": "geojson"}
with pytest.raises(NotImplementedError):
Expand Down

0 comments on commit ec36997

Please sign in to comment.