Skip to content

Commit 66e1d47

Browse files
Merge branch 'develop' into feature/exposures_hdf5_io
2 parents 5e8e583 + a5a3fef commit 66e1d47

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

climada/test/test_litpop_integr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def test_netherlands150_pass(self):
5353
self.assertEqual(ent.gdf.shape[0], 2829)
5454

5555
def test_BLM150_pass(self):
56-
"""Test from_countries for BLM at 150 arcsec, 2 data points"""
56+
"""Test from_countries for BLM at 150 arcsec, 2 data points
57+
The world bank doesn't provide data for Saint Barthélemy, fall back to natearth
58+
"""
5759
ent = lp.LitPop.from_countries("BLM", res_arcsec=150, reference_year=2016)
5860
self.assertEqual(ent.gdf.shape[0], 2)
5961

climada/util/finance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def download_world_bank_indicator(
216216
# Check if we received an error message
217217
try:
218218
if json_data[0]["message"][0]["id"] == "120":
219-
raise RuntimeError(
219+
raise ValueError(
220220
"Error requesting data from the World Bank API. Did you use the "
221221
"correct country code and indicator ID?"
222222
)

climada/util/test/test_finance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ def test_download_wb_data(self):
151151

152152
# Check errors raised
153153
with self.assertRaisesRegex(
154-
RuntimeError,
154+
ValueError,
155155
"Did you use the correct country code",
156156
):
157157
download_world_bank_indicator("Spain", "NY.GDP.MKTP.CD")
158158
with self.assertRaisesRegex(
159-
RuntimeError,
159+
ValueError,
160160
"Did you use the correct country code",
161161
):
162162
download_world_bank_indicator("ESP", "BogusIndicator")

script/jenkins/test_data_api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import numpy as np
2727
import pytest
28-
from pandas_datareader import wb
2928

3029
from climada import CONFIG
3130
from climada.entity.exposures.litpop.nightlight import BM_FILENAMES, download_nl_files
@@ -36,7 +35,11 @@
3635
download_icon_grib,
3736
)
3837
from climada.util.files_handler import download_file, download_ftp
39-
from climada.util.finance import WORLD_BANK_INC_GRP, WORLD_BANK_WEALTH_ACC
38+
from climada.util.finance import (
39+
WORLD_BANK_INC_GRP,
40+
WORLD_BANK_WEALTH_ACC,
41+
download_world_bank_indicator,
42+
)
4043

4144

4245
class TestDataAvail(unittest.TestCase):
@@ -75,7 +78,8 @@ def test_wb_lev_hist_pass(self):
7578

7679
def test_wb_api_pass(self):
7780
"""Test World Bank API"""
78-
wb.download(indicator="NY.GDP.MKTP.CD", country="CHE", start=1960, end=2030)
81+
download_world_bank_indicator(indicator="NY.GDP.MKTP.CD", country_code="CHE")
82+
# as this doesn't download to a file, there is nothing to unlink
7983

8084
def test_ne_api_pass(self):
8185
"""Test Natural Earth API"""

0 commit comments

Comments
 (0)