Skip to content

Commit

Permalink
Merge pull request #1288 from python-discord/return-bytes-io-from-htt…
Browse files Browse the repository at this point in the history
…p-errors

Return BytesIO as fp for mocked HTTP errors
  • Loading branch information
jb3 authored Apr 1, 2024
2 parents d80a1f7 + 3a4c2e3 commit cf36f01
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pydis_site/apps/api/tests/test_github_webhook_filter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
from unittest import mock
from urllib.error import HTTPError

Expand Down Expand Up @@ -58,6 +59,7 @@ def test_rate_limit_is_logged_to_sentry(self):
mock.patch.object(GitHubWebhookFilterView, "logger") as logger,
):
urlopen.side_effect = HTTPError(None, 429, 'Too Many Requests', {}, None)
urlopen.side_effect.fp = io.BytesIO()
logger.warning = mock.PropertyMock()
self.client.post(url, data=payload, headers=headers)

Expand All @@ -72,6 +74,7 @@ def test_other_error_is_logged(self):
mock.patch.object(GitHubWebhookFilterView, "logger") as logger,
):
urlopen.side_effect = HTTPError(None, 451, 'Unavailable For Legal Reasons', {}, None)
urlopen.side_effect.fp = io.BytesIO()
logger.warning = mock.PropertyMock()
self.client.post(url, data=payload, headers=headers)

Expand Down

0 comments on commit cf36f01

Please sign in to comment.