Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
[api] fix None reason throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
b1naryth1ef committed Jun 27, 2017
1 parent 20b9e49 commit 6ba556c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion disco/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def optional(**kwargs):


def _reason_header(value):
return optional(**{'X-Audit-Log-Reason': quote(to_bytes(value))})
return optional(**{'X-Audit-Log-Reason': quote(to_bytes(value)) if value else None})


class APIClient(LoggingClass):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ def test_set_unicode_reason(self):

_, kwargs = api.http.calls[0]
self.assertEqual(kwargs['headers']['X-Audit-Log-Reason'], 'yo%20%F0%9F%92%BF%20test')

def test_null_reason(self):
from tests.utils import TestAPIClient
api = TestAPIClient()
api.guilds_channels_modify(1, 2, 3, reason=None)

_, kwargs = api.http.calls[0]
self.assertFalse('X-Audit-Log-Reason' in kwargs['headers'])

0 comments on commit 6ba556c

Please sign in to comment.