-
Notifications
You must be signed in to change notification settings - Fork 297
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
patch occasional UnicodeEncodeError
that occurs with outgoing webhooks
#3832
Conversation
that occurs with outgoing webhooks
ALERT_GROUP_PUBLIC_PRIMARY_KEY = "IXJ47FKMYYJ5U" | ||
|
||
|
||
@httpretty.activate(verbose=True, allow_net_connect=False) |
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 exception I was trying to fix, and fully test, here happens rather deep inside the requests
package (logs). Rather than trying to figure out what to properly mock there I decided to try out httpretty
which according to their docs:
It can be a bit of a hassle to use something like mock.Mock to stub the requests, this can work well for low-level unit tests but when writing functional or integration tests we should be able to allow the http calls to go through the TCP socket module.
HTTPretty monkey patches Python’s socket core module with a fake version of the module.
Because HTTPretty implements a fake the modules socket and ssl you can use write tests to code against any HTTP library that use those modules.
in other words, we don't have to patch requests
at all (note: I'm patch
ing requests
but w/ the wraps
kwarg which basically sets a "spy" on the package and doesn't mock its actual implementation (docs))
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.
LGTM
Which issue(s) this PR fixes
Closes #3831
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)