Skip to content

Commit

Permalink
Fix exception handling when requesting 404 resources using fsspec
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Aug 14, 2021
1 parent 768bbe3 commit 8665741
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions tests/provider/dwd/observation/test_fileindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions tests/provider/dwd/observation/test_metaindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit 8665741

Please sign in to comment.