Skip to content

Commit 002628b

Browse files
committed
Add information to error message
1 parent b96b1ca commit 002628b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tests/test_wind_turbine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_wrong_url_load_turbine_data(self):
5252
"""Load turbine data from oedb."""
5353

5454
with pytest.raises(
55-
ConnectionError, match="Database connection not successful"
55+
ConnectionError, match="Not found"
5656
):
5757
load_turbine_data_from_oedb("wrong_schema")
5858

windpowerlib/wind_turbine.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,19 @@ def load_turbine_data_from_oedb(schema="supply", table="wind_turbine_library"):
454454
"""
455455
# url of OpenEnergy Platform that contains the oedb
456456
oep_url = "http://oep.iks.cs.ovgu.de/"
457+
url = oep_url + "/api/v0/schema/{}/tables/{}/rows/?".format(schema, table)
457458

458459
# load data
459-
result = requests.get(
460-
oep_url + "/api/v0/schema/{}/tables/{}/rows/?".format(schema, table),
461-
)
460+
result = requests.get(url)
461+
print(result.json())
462462
if not result.status_code == 200:
463463
raise ConnectionError(
464-
"Database connection not successful. "
465-
"Response: [{}]".format(result.status_code)
464+
"Database (oep) connection not successful. \nURL: {2}\n"
465+
"Response: [{0}] \n{1}".format(
466+
result.status_code, result.text, url
467+
)
466468
)
469+
467470
# extract data to dataframe
468471
turbine_data = pd.DataFrame(result.json())
469472
# standard file name for saving data

0 commit comments

Comments
 (0)