Repository: NOAA-OWP/hydrotools (language: python)

Issue:
"Run Slow Unit Tests" Action has been failing for some time
As @jarq6c mentioned in #216, the "Run Slow Unit Tests" Action has been failing for some time. I did a little bit of digging and the issue is twofold. First, the `svi_client` is missing a testing dependency, `pytest-aiohttp`. We use this dependecny in `_restclient` and `nwis_client` to provide an `asyncio` loop to tests. This is the cause of the `RuntimeError: There is no current event loop in thread 'MainThread'.` errors in the slow unit tests. Second, in general the `svi_client` integration tests are a little brittle. We end up hitting an esri feature server repeatedly upwards of 600 times. If requests are made too quickly, the server just rejects the requests.



Discussion / hints:

Fix patch:
diff --git a/python/svi_client/setup.cfg b/python/svi_client/setup.cfg
index 8c26047c..6085b585 100644
--- a/python/svi_client/setup.cfg
+++ b/python/svi_client/setup.cfg
@@ -47,3 +47,4 @@ where = src
 [options.extras_require]
 develop =
     pytest
+    pytest-aiohttp


Test patch:
diff --git a/python/svi_client/tests/test_integration.py b/python/svi_client/tests/test_integration.py
index 85deae1c..64efd5d8 100644
--- a/python/svi_client/tests/test_integration.py
+++ b/python/svi_client/tests/test_integration.py
@@ -63,7 +63,7 @@
 @pytest.mark.parametrize("location", LOCATIONS)
 @pytest.mark.parametrize("year", YEARS)
 @pytest.mark.parametrize("scale", GEOGRAPHIC_SCALES)
-def test_svi_client_get_integration(location, year, scale):
+def test_svi_client_get_integration(location, year, scale, loop):
     client = SVIClient(enable_cache=False)
     df = client.get(location, scale, year)
     assert df.loc[0, "state_abbreviation"] == location
@@ -72,7 +72,7 @@ def test_svi_client_get_integration(location, year, scale):
 @pytest.mark.slow
 @pytest.mark.parametrize("year", YEARS)
 @pytest.mark.parametrize("scale", GEOGRAPHIC_SCALES)
-def test_svi_client_get_integration_us(year, scale):
+def test_svi_client_get_integration_us(year, scale, loop):
     client = SVIClient(enable_cache=False)
     df = client.get("us", scale, year)
     assert df.state_abbreviation.isin(LOCATIONS).all()