-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix CAMS message error handler #1905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
a02bb78
1da05c0
05f9e93
81bfc8f
e6a49cd
3bc9d33
9c11d8f
c544a49
892dd0e
dd0a572
80c4fa4
64972a1
f130248
fcf8845
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,20 +248,21 @@ def test_get_cams_bad_request(requests_mock): | |
requests inputs. Also tests if the specified server url gets used""" | ||
|
||
# Subset of an xml file returned for errornous requests | ||
mock_response_bad = """<?xml version="1.0" encoding="utf-8"?> | ||
mock_response_bad_text = """<?xml version="1.0" encoding="utf-8"?> | ||
<ows:Exception exceptionCode="NoApplicableCode" locator="None"> | ||
<ows:ExceptionText>Failed to execute WPS process [get_mcclear]: | ||
Please, register yourself at www.soda-pro.com | ||
</ows:ExceptionText>""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this error text is out of date. From the real API, I get this response when supplying an unregistered email:
Probably we should update to the current API message, right? Note also that the end of the message seems to be truncated ("Please, " do what?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see this error message has already been discussed :) If it will change again soon, what should we do here? I don't think it makes sense to test on out of date messages, but it seems that even the current message will soon be out of date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the message will be changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it is not critical that the text be an exact match, but we should still try to mimic the real API's behavior to whatever extent is possible. In this case, maybe the best we can do is to add a comment in the test saying that this text isn't an exact match. |
||
|
||
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 | ||
|
||
requests_mock.get(url_cams_bad_request, text=mock_response_bad, | ||
headers={'Content-Type': 'application/xml'}) | ||
requests_mock.get(url_cams_bad_request, status_code=400, | ||
text=mock_response_bad_text) | ||
|
||
# Test if HTTPError is raised if incorrect input is specified | ||
# In the below example a non-registrered email is specified | ||
with pytest.raises(requests.HTTPError, match='Failed to execute WPS'): | ||
with pytest.raises(requests.exceptions.HTTPError, | ||
match='Failed to execute WPS process'): | ||
_ = sodapro.get_cams( | ||
start=pd.Timestamp('2020-01-01'), | ||
end=pd.Timestamp('2020-05-04'), | ||
|
Uh oh!
There was an error while loading. Please reload this page.