diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5789ab3..905ebb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy exclude: docs/source/conf.py @@ -50,7 +50,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.6 + rev: v0.6.3 hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/tests/test_erddapy.py b/tests/test_erddapy.py index 3e367b9..b84dc68 100644 --- a/tests/test_erddapy.py +++ b/tests/test_erddapy.py @@ -90,8 +90,8 @@ def test__format_constraints_url(): assert kw_url == "&latitude>=42&longitude<=42.0" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_erddap2_10(): """Check regression for ERDDAP 2.10.""" e = ERDDAP(server="http://erddap.ioos.us/erddap/") diff --git a/tests/test_multiple_server_search.py b/tests/test_multiple_server_search.py index 338809c..b858b06 100644 --- a/tests/test_multiple_server_search.py +++ b/tests/test_multiple_server_search.py @@ -7,8 +7,8 @@ from erddapy.multiple_server_search import fetch_results, search_servers -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_fetch_results(): """Test searches should return results.""" url = ( @@ -21,8 +21,8 @@ def test_fetch_results(): assert data is not None -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_fetch_no_results(): """Test searches that should return no results.""" url = ( @@ -35,7 +35,7 @@ def test_fetch_no_results(): assert data is None -@pytest.mark.web() +@pytest.mark.web @pytest.mark.skipif( sys.platform in ["win32", "darwin"], reason="run only on linux to avoid extra load on the server", @@ -51,7 +51,7 @@ def test_search_awesome_erddap_servers_true(): assert not df.empty -@pytest.mark.web() +@pytest.mark.web @pytest.mark.skipif( sys.platform in ["win32", "darwin"], reason="run only on linux to avoid extra load on the server", @@ -67,8 +67,8 @@ def test_search_awesome_erddap_servers_false(): assert not df.empty -@pytest.fixture() -@pytest.mark.web() +@pytest.fixture +@pytest.mark.web def servers_list(): """Objects for server search.""" return { @@ -81,7 +81,7 @@ def servers_list(): } -@pytest.mark.web() +@pytest.mark.web @pytest.mark.skipif( (sys.platform in ["win32", "darwin"] or sys.version_info < (3, 10)), reason="run only on linux and latest to avoid extra load on the server", @@ -104,8 +104,8 @@ def test_search_servers_with_a_list_parallel_true(servers_list): assert not df.empty -@pytest.mark.vcr() -@pytest.mark.web() +@pytest.mark.vcr +@pytest.mark.web @pytest.mark.skipif( sys.platform in ["win32", "darwin"], reason="run only on linux to avoid extra load on the server", diff --git a/tests/test_netcdf_handling.py b/tests/test_netcdf_handling.py index 146a0a0..43b51d3 100644 --- a/tests/test_netcdf_handling.py +++ b/tests/test_netcdf_handling.py @@ -9,7 +9,7 @@ from erddapy.core.url import urlopen -@pytest.mark.web() +@pytest.mark.web # For some reason we cannot use vcr with httpx with in_memory # (also all the to_objects that uses in_memory). def test__nc_dataset_in_memory_https(): @@ -22,8 +22,8 @@ def test__nc_dataset_in_memory_https(): assert _nc.filepath() == url.split("/")[-1] -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr @pytest.mark.skipif( platform.system().lower() == "windows", reason="does not remove the file on windows", diff --git a/tests/test_servers.py b/tests/test_servers.py index 9141c0b..0a3625c 100644 --- a/tests/test_servers.py +++ b/tests/test_servers.py @@ -6,8 +6,8 @@ from erddapy.core.url import check_url_response -@pytest.mark.web() -@pytest.mark.xfail() +@pytest.mark.web +@pytest.mark.xfail def test_servers(): """Tests if listed servers are responding. diff --git a/tests/test_to_objects.py b/tests/test_to_objects.py index 5f3f5b8..a82c447 100644 --- a/tests/test_to_objects.py +++ b/tests/test_to_objects.py @@ -14,8 +14,8 @@ dask.config.set(scheduler="single-threaded") -@pytest.fixture() -@pytest.mark.web() +@pytest.fixture +@pytest.mark.web def sensors(): """Instantiate ERDDAP class for testing.""" return ERDDAP( @@ -24,8 +24,8 @@ def sensors(): ) -@pytest.fixture() -@pytest.mark.web() +@pytest.fixture +@pytest.mark.web def gliders(): """Instantiate ERDDAP class for testing.""" # The gliders server has 1244 datasets at time of writing @@ -35,8 +35,8 @@ def gliders(): ) -@pytest.fixture() -@pytest.mark.web() +@pytest.fixture +@pytest.mark.web def neracoos(): """Instantiate ERDDAP class for testing.""" return ERDDAP( @@ -45,7 +45,7 @@ def neracoos(): ) -@pytest.fixture() +@pytest.fixture def dataset_griddap(neracoos): """Load griddap data for testing.""" neracoos.dataset_id = "WW3_EastCoast_latest" @@ -54,7 +54,7 @@ def dataset_griddap(neracoos): return neracoos -@pytest.fixture() +@pytest.fixture def dataset_opendap(neracoos): """Load griddap data with OPeNDAP response for testing.""" neracoos.dataset_id = "WW3_EastCoast_latest" @@ -63,7 +63,7 @@ def dataset_opendap(neracoos): return neracoos -@pytest.fixture() +@pytest.fixture def dataset_tabledap(sensors): """Load tabledap for testing.""" sensors.dataset_id = "amelia_20180501t0000" @@ -80,7 +80,7 @@ def dataset_tabledap(sensors): return sensors -@pytest.mark.web() +@pytest.mark.web def test_csv_search(gliders): """Test if a CSV search returns all items (instead of the first 1000).""" url = gliders.get_search_url(search_for="all", response="csv") @@ -90,7 +90,7 @@ def test_csv_search(gliders): assert nrows > expected -@pytest.mark.web() +@pytest.mark.web def test_json_search(gliders): """Test if a JSON search returns all items (instead of the first 1000).""" url = gliders.get_search_url(search_for="all", response="json") @@ -100,8 +100,8 @@ def test_json_search(gliders): assert nrows > expected -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_to_pandas(dataset_tabledap): """Test converting tabledap to a pandas DataFrame.""" import pandas as pd @@ -117,8 +117,8 @@ def test_to_pandas(dataset_tabledap): assert df.columns[0] == "temperature (degree_Celsius)" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_to_pandas_requests_kwargs(dataset_tabledap): """Test if to_pandas_requests_kwargs are processed as expected.""" import pandas as pd @@ -134,7 +134,7 @@ def test_to_pandas_requests_kwargs(dataset_tabledap): assert is_datetime64_any_dtype(df.index) -@pytest.mark.web() +@pytest.mark.web def test_to_xarray_tabledap(dataset_tabledap): """Test converting tabledap to an xarray Dataset.""" ds = dataset_tabledap.to_xarray() @@ -146,7 +146,7 @@ def test_to_xarray_tabledap(dataset_tabledap): assert ds["temperature"].name == "temperature" -@pytest.mark.web() +@pytest.mark.web def test_to_xarray_requests_kwargs(dataset_tabledap): """Test converting tabledap to an xarray Dataset with manual timeout.""" ds = dataset_tabledap.to_xarray(requests_kwargs={"timeout": 30}) @@ -158,21 +158,21 @@ def test_to_xarray_requests_kwargs(dataset_tabledap): assert ds["temperature"].name == "temperature" -@pytest.mark.web() +@pytest.mark.web def test_to_xarray_griddap(dataset_griddap): """Test converting griddap to an xarray Dataset.""" ds = dataset_griddap.to_xarray() assert isinstance(ds, xr.Dataset) -@pytest.mark.web() +@pytest.mark.web def test_to_xarray_opendap(dataset_opendap): """Test converting griddap to xarray with the OPeNDAP response.""" ds = dataset_opendap.to_xarray() assert isinstance(ds, xr.Dataset) -@pytest.mark.web() +@pytest.mark.web def test_to_xarray_opendap_griddap_initialize(dataset_opendap): """Test converting griddap aftert calling griddap_initialize.""" dataset_opendap.griddap_initialize() @@ -180,7 +180,7 @@ def test_to_xarray_opendap_griddap_initialize(dataset_opendap): assert isinstance(ds, xr.Dataset) -@pytest.mark.web() +@pytest.mark.web @pytest.mark.skipif( (sys.platform in ("win32", "darwin")), reason="run this test until we figure out a way to mock it.", @@ -197,7 +197,7 @@ def test_to_iris_tabledap(dataset_tabledap): ) -@pytest.mark.web() +@pytest.mark.web @pytest.mark.skipif( (sys.platform in ("win32", "darwin")), reason="run this test until we figure out a way to mock it.", @@ -208,7 +208,7 @@ def test_to_iris_griddap(dataset_griddap): assert isinstance(cubes, iris.cube.CubeList) -@pytest.mark.web() +@pytest.mark.web def test_download_file(dataset_tabledap): """Test file download of tabledap with defined variable and constraints.""" fn = dataset_tabledap.download_file("nc") @@ -220,7 +220,7 @@ def test_download_file(dataset_tabledap): assert fn_new == fn -@pytest.mark.web() +@pytest.mark.web def test_download_file_variables_only(dataset_tabledap): """Test direct download of tabledap dataset with undefined constraints.""" dataset_tabledap.constraints = {} @@ -233,7 +233,7 @@ def test_download_file_variables_only(dataset_tabledap): assert fn_new == fn -@pytest.mark.web() +@pytest.mark.web def test_download_file_constraints_only(dataset_tabledap): """Test direct download of tabledap dataset with undefined variables.""" dataset_tabledap.variables = [] @@ -246,7 +246,7 @@ def test_download_file_constraints_only(dataset_tabledap): assert fn_new == fn -@pytest.mark.web() +@pytest.mark.web def test_download_file_undefined_query(dataset_tabledap): """Test direct download of tabledap dataset with undefined query.""" dataset_tabledap.variables = [] diff --git a/tests/test_url_builder.py b/tests/test_url_builder.py index cee9bd7..586aa8c 100644 --- a/tests/test_url_builder.py +++ b/tests/test_url_builder.py @@ -11,7 +11,7 @@ def _url_to_dict(url): return {v.split("=")[0]: v.split("=")[1] for v in url.split("&")[1:]} -@pytest.fixture() +@pytest.fixture def e(): """Instantiate ERDDAP class for testing.""" return ERDDAP( @@ -21,8 +21,8 @@ def e(): ) -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_search_url_bad_request(e): """Test if a bad request returns HTTPError.""" kw = { @@ -43,8 +43,8 @@ def test_search_normalization(e): assert "timeseries" in search_url -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_search_url_valid_request(e): """Test if a bad request returns HTTPError.""" min_time = "2000-03-23T00:00:00Z" @@ -64,8 +64,8 @@ def test_search_url_valid_request(e): assert v == "(ANY)" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_search_url_valid_request_with_relative_time_constraints(e): """Test if a bad request returns HTTPError.""" min_time = "now-25years" @@ -85,8 +85,8 @@ def test_search_url_valid_request_with_relative_time_constraints(e): assert v == "(ANY)" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_search_url_change_protocol(e): """Test if we change the protocol it show in the URL.""" kw = {"search_for": "salinity"} @@ -109,8 +109,8 @@ def test_search_url_change_protocol(e): assert options.pop("protocol") == "(ANY)" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_info_url(e): """Check info URL results.""" dataset_id = "org_cormp_cap2" @@ -123,8 +123,8 @@ def test_info_url(e): assert url == f"{e.server}/info/{dataset_id}/index.csv" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_categorize_url(e): """Check categorize URL results.""" categorize_by = "standard_name" @@ -135,8 +135,8 @@ def test_categorize_url(e): assert url == f"{e.server}/categorize/{categorize_by}/index.csv" -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_download_url_unconstrained(e): """Check download URL results.""" dataset_id = "org_cormp_cap2" @@ -149,8 +149,8 @@ def test_download_url_unconstrained(e): assert sorted(url.split("?")[1].split(",")) == sorted(variables) -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_download_url_constrained(e): """Test a constraint download URL.""" dataset_id = "org_cormp_cap2" @@ -230,8 +230,8 @@ def test_download_url_relative_constraints(e): assert options["longitude<"] == max_lon -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_get_var_by_attr(e): """Test get_var_by_attr.""" variables = e.get_var_by_attr(dataset_id="org_cormp_cap2", axis="X") @@ -259,8 +259,8 @@ def test_get_var_by_attr(e): ] -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_download_url_distinct(e): """Check download URL results with and without the distinct option.""" dataset_id = "org_cormp_cap2" diff --git a/tests/test_url_handling.py b/tests/test_url_handling.py index cb604d8..90377e7 100644 --- a/tests/test_url_handling.py +++ b/tests/test_url_handling.py @@ -8,8 +8,8 @@ from erddapy.core.url import _sort_url, check_url_response, urlopen -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_urlopen(): """Assure that urlopen is always a BytesIO object.""" url = "https://standards.sensors.ioos.us/erddap/tabledap/" @@ -17,8 +17,8 @@ def test_urlopen(): isinstance(ret, io.BytesIO) -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_urlopen_raise(): """Assure that urlopen will raise for bad URLs.""" url = "https://developer.mozilla.org/en-US/404" @@ -26,8 +26,8 @@ def test_urlopen_raise(): urlopen(url) -@pytest.mark.web() -@pytest.mark.vcr() +@pytest.mark.web +@pytest.mark.vcr def test_check_url_response(): """Test if a bad request returns HTTPError.""" bad_request = (