Skip to content

Commit

Permalink
Merge pull request #2 from thodson-usgs/wqx3-work
Browse files Browse the repository at this point in the history
Fix mimetype test
  • Loading branch information
ehinman authored Sep 17, 2024
2 parents 3a8c818 + 089354c commit 91947ad
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions tests/wqp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

from pandas import DataFrame

from dataretrieval.wqp import (get_results, what_sites, what_organizations,
what_projects, what_activities,
what_detection_limits, what_habitat_metrics,
what_project_weights, what_activity_metrics,
_alter_kwargs)
from dataretrieval.wqp import (
get_results,
what_sites,
what_organizations,
what_projects,
what_activities,
what_detection_limits,
what_habitat_metrics,
what_project_weights,
what_activity_metrics,
_check_mimetype,
)


def test_get_results(requests_mock):
Expand Down Expand Up @@ -171,12 +178,11 @@ def mock_request(requests_mock, request_url, file_path):
requests_mock.get(request_url, text=text.read(), headers={"mock_header": "value"})


class TestAlterKwargs:
"""Tests for keyword alteration.
"""
def test_alter_kwargs_mimetype(self):
"""Tests that mimetype kwarg is altered correctly and warning is thrown."""
kwargs = {"mimeType": "geojson"}
with pytest.warns(UserWarning):
kwargs = _alter_kwargs(kwargs)
assert kwargs == {"mimeType": "csv"}
def test_check_mimetype(self):
"""Tests that correct errors are raised for invalid mimetypes."""
kwargs = {"mimeType": "geojson"}
with pytest.raises(NotImplementedError):
kwargs = _check_mimetype(kwargs)
kwargs = {"mimeType": "foo"}
with pytest.raises(ValueError):
kwargs = _check_mimetype(kwargs)

0 comments on commit 91947ad

Please sign in to comment.