generated from kivy-garden/flower
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checks HTTP response status code, fixes #6
On error in the HTTP status code, the callback function will no longer be called.
- Loading branch information
1 parent
937e5a9
commit 8aa5e57
Showing
3 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
from unittest import mock | ||
|
||
from requests.models import Response | ||
|
||
def patch_requests_get(response_json=None): | ||
response = mock.Mock() | ||
response.return_value.json.return_value = response_json | ||
return mock.patch("requests.get", response) | ||
|
||
def patch_requests_get(response_json=None, status_code=200): | ||
response = Response() | ||
response.json = lambda: response_json | ||
response.status_code = status_code | ||
m_get = mock.Mock(return_value=response) | ||
return mock.patch("requests.get", m_get) |