From 86657416f5447f66088d59d26a743d138129b886 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Tue, 10 Aug 2021 23:19:34 +0200 Subject: [PATCH] Fix exception handling when requesting 404 resources using fsspec --- tests/provider/dwd/observation/test_fileindex.py | 12 ++++++++++-- tests/provider/dwd/observation/test_metaindex.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/provider/dwd/observation/test_fileindex.py b/tests/provider/dwd/observation/test_fileindex.py index 895e52d06..bb842e9b0 100644 --- a/tests/provider/dwd/observation/test_fileindex.py +++ b/tests/provider/dwd/observation/test_fileindex.py @@ -21,7 +21,7 @@ @pytest.mark.remote -def test_file_index_creation(): +def test_file_index_creation_success(): # Existing combination of parameters file_index = create_file_index_for_climate_observations( @@ -40,8 +40,16 @@ def test_file_index_creation(): "climate/daily/kl/recent/tageswerte_KL_01048_akt.zip" ] + +@pytest.mark.remote +def test_file_index_creation_failure(): + with pytest.raises( - (requests.exceptions.HTTPError, aiohttp.client_exceptions.ClientResponseError) + ( + requests.exceptions.HTTPError, + aiohttp.client_exceptions.ClientResponseError, + FileNotFoundError, + ) ): create_file_index_for_climate_observations( DwdObservationDataset.CLIMATE_SUMMARY, diff --git a/tests/provider/dwd/observation/test_metaindex.py b/tests/provider/dwd/observation/test_metaindex.py index e475a1cfa..a3f7a72da 100644 --- a/tests/provider/dwd/observation/test_metaindex.py +++ b/tests/provider/dwd/observation/test_metaindex.py @@ -16,7 +16,7 @@ @pytest.mark.remote -def test_meta_index_creation(): +def test_meta_index_creation_success(): # Existing combination of parameters meta_index = create_meta_index_for_climate_observations( @@ -27,8 +27,16 @@ def test_meta_index_creation(): assert not meta_index.empty + +@pytest.mark.remote +def test_meta_index_creation_failure(): + with pytest.raises( - (requests.exceptions.HTTPError, aiohttp.client_exceptions.ClientResponseError) + ( + requests.exceptions.HTTPError, + aiohttp.client_exceptions.ClientResponseError, + FileNotFoundError, + ) ): create_meta_index_for_climate_observations( DwdObservationDataset.CLIMATE_SUMMARY,