Skip to content

Commit 60f58ce

Browse files
committed
Ignore ssl and add test to detect a working ssl connection
1 parent 96de09f commit 60f58ce

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

tests/test_data_handling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pandas as pd
1111
import pytest
12+
import requests
1213
from windpowerlib.data import (
1314
check_data_integrity,
1415
check_turbine_data,
@@ -101,6 +102,23 @@ def test_wrong_url_load_turbine_data(self):
101102
):
102103
store_turbine_data_from_oedb("wrong_schema")
103104

105+
def test_wrong_ssl_connection(self):
106+
"""Test failing ssl connection. To avoid this error in data.py the in
107+
the function fetch_turbine_data_from_oedb in data.py verify was set
108+
to False to ignore the exception in the requests statement.
109+
110+
If this test fails you can set verify to True and remove this test if
111+
all the other tests work fine.
112+
"""
113+
schema = "supply"
114+
table = "wind_turbine_library"
115+
oep_url = "https://oep.iks.cs.ovgu.de/"
116+
url = oep_url + "/api/v0/schema/{}/tables/{}/rows/?".format(
117+
schema, table
118+
)
119+
with pytest.raises(requests.exceptions.SSLError):
120+
requests.get(url, verify=True)
121+
104122
def test_restore_default_data(self):
105123
"""Test the clean recovery of the data files."""
106124
names = ["turbine_data", "power_curves", "power_coefficient_curves"]

windpowerlib/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ def fetch_turbine_data_from_oedb(
133133
134134
"""
135135
# url of OpenEnergy Platform that contains the oedb
136-
oep_url = "http://oep.iks.cs.ovgu.de/"
136+
oep_url = "https://oep.iks.cs.ovgu.de/"
137137
url = oep_url + "/api/v0/schema/{}/tables/{}/rows/?".format(schema, table)
138138

139139
# load data
140-
result = requests.get(url)
140+
result = requests.get(url, verify=False)
141141
if not result.status_code == 200:
142142
raise ConnectionError(
143143
"Database (oep) connection not successful. \nURL: {2}\n"

0 commit comments

Comments
 (0)