Skip to content

Commit e6a49cd

Browse files
author
GillesFischerV
committed
Fix associated UT and add contribution in WhatsNews
1 parent 81bfc8f commit e6a49cd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

docs/sphinx/source/whatsnew/v0.10.3.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Enhancements
1515

1616
Bug fixes
1717
~~~~~~~~~
18-
18+
* Fixed CAMS error message handler in
19+
:py:func:`pvlib.iotools.sodapro.get_cams` (:issue:`1799`, :pull:`1905`)
1920

2021
Testing
2122
~~~~~~~
@@ -32,3 +33,4 @@ Contributors
3233
* Miguel Sánchez de León Peque (:ghuser:`Peque`)
3334
* Will Hobbs (:ghuser:`williamhobbs`)
3435
* Anton Driesse (:ghuser:`adriesse`)
36+
* Gilles Fischer (:ghuser: `GillesFischerV`)

pvlib/iotools/sodapro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
225225
res.reason = "%s: <%s>" % (res.reason, errors)
226226
res.raise_for_status()
227227
# Successful requests returns a csv data file
228-
elif res.headers['Content-Type'] == 'application/csv':
228+
else:
229229
fbuf = io.StringIO(res.content.decode('utf-8'))
230230
data, metadata = parse_cams(fbuf, integrated=integrated, label=label,
231231
map_variables=map_variables)

pvlib/tests/iotools/test_sodapro.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,20 @@ def test_get_cams_bad_request(requests_mock):
248248
requests inputs. Also tests if the specified server url gets used"""
249249

250250
# Subset of an xml file returned for errornous requests
251-
mock_response_bad = """<?xml version="1.0" encoding="utf-8"?>
251+
mock_response_bad_text = """<?xml version="1.0" encoding="utf-8"?>
252252
<ows:Exception exceptionCode="NoApplicableCode" locator="None">
253253
<ows:ExceptionText>Failed to execute WPS process [get_mcclear]:
254254
Please, register yourself at www.soda-pro.com
255255
</ows:ExceptionText>"""
256256

257257
url_cams_bad_request = 'https://pro.soda-is.com/service/wps?DataInputs=latitude=55.7906;longitude=12.5251;altitude=-999;date_begin=2020-01-01;date_end=2020-05-04;time_ref=TST;summarization=PT01H;username=test%2540test.com;verbose=false&Service=WPS&Request=Execute&Identifier=get_mcclear&version=1.0.0&RawDataOutput=irradiation' # noqa: E501
258258

259-
requests_mock.get(url_cams_bad_request, text=mock_response_bad,
260-
headers={'Content-Type': 'application/xml'})
259+
requests_mock.get(url_cams_bad_request, status_code=400,
260+
text=mock_response_bad_text)
261261

262262
# Test if HTTPError is raised if incorrect input is specified
263263
# In the below example a non-registrered email is specified
264-
with pytest.raises(requests.HTTPError, match='Failed to execute WPS'):
264+
with pytest.raises(requests.exceptions.HTTPError, match='Failed to execute WPS process'):
265265
_ = sodapro.get_cams(
266266
start=pd.Timestamp('2020-01-01'),
267267
end=pd.Timestamp('2020-05-04'),

0 commit comments

Comments
 (0)