Skip to content

Commit

Permalink
add nwis_client context manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshCu authored and aaraney committed Oct 8, 2024
1 parent 51153d2 commit f49397f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions python/nwis_client/tests/test_nwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def wrap_iv_cache_location_to_temp(loop):

o = partial(iv.IVDataService, cache_filename=cache_file)
return o


@pytest.fixture
def setup_iv(IVDataServiceWithTempCache):
Expand Down Expand Up @@ -119,7 +119,7 @@ def mocked_iv(mock_iv, setup_iv):
`iv.IVDataService`'s `get_raw` method has been mocked to return an empty list.
"""
return setup_iv


simplify_variable_test_data = [
("test", ",", "test"),
Expand Down Expand Up @@ -556,6 +556,17 @@ def test_nwis_client_cache_path(loop):
# close resources
service._restclient.close()


@pytest.mark.slow
def test_nwis_client_context_manager(loop):
"""verify that context manager closes resources"""
with iv.IVDataService() as service:
service.get(sites=["01189000"], startDT="2022-01-01")
assert service._restclient._session.closed
# should this be closed? The assertion fails if uncommented
# assert service._restclient._loop.is_closed()


def test_fixes_209(loop, monkeypatch):
"""
verify that pandas FutureWarning is not raised by `IVDataService.get`. This FutureWarning was
Expand Down

0 comments on commit f49397f

Please sign in to comment.