-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add WriteInPublic API client #2344
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor things I've commented on inline but otherwise this looks good 👍
pombola/writeinpublic/client.py
Outdated
try: | ||
return requests.post(url, json=payload, params=params) | ||
except requests.exceptions.RequestException as err: | ||
raise self.WriteInPublicException(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument to this exceptions constructor is expected to be a string, I think, so perhaps this should be:
raise self.WriteInPublicException(unicode(err))
'api_key': self.api_key, | ||
'person__popolo_uri': person_popolo_uri, | ||
} | ||
response = requests.get(url, params=params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all calls to requests.get
or requests.post
should be followed by response.raise_for_status()
afterwards, or you won't get an exception for 4xx and 5xx responses, and will get a less helpful error later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good shout, I didn't know about that method, added that in de1f549.
@mhl I've made those changes now, so I think this is ready for another review. |
This is a very simple wrapper around the WriteInPublic API. Currently it only implements the features that we need for integrating it into Pombola. I've added some tests for the basic functionality, but in the interests of time I've skipped writing tests for the .people() and .answers() methods, so will need to revisit that at some point in the future.
de1f549
to
6fdab17
Compare
This is a very simple wrapper around the WriteInPublic API. Currently it only implements the features that we need for integrating it into Pombola.
I've added some tests for the basic functionality, but in the interests of time I've skipped writing tests for the
.people()
and.answers()
methods, so will need to revisit that at some point in the future.Extracted from #2329
Part of #1682