Skip to content

Commit

Permalink
Merge pull request tindie#5 from jdorweiler/master
Browse files Browse the repository at this point in the history
pass params in data
  • Loading branch information
bennylope authored Sep 9, 2016
2 parents acdcb03 + f8d6289 commit 811453a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pydiscourse/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def _get(self, path, **kwargs):
Returns:
"""
return self._request(GET, path, kwargs)
return self._request(GET, path, params=kwargs)

def _put(self, path, **kwargs):
"""
Expand All @@ -805,7 +805,7 @@ def _put(self, path, **kwargs):
Returns:
"""
return self._request(PUT, path, kwargs)
return self._request(PUT, path, data=kwargs)

def _post(self, path, **kwargs):
"""
Expand All @@ -817,7 +817,7 @@ def _post(self, path, **kwargs):
Returns:
"""
return self._request(POST, path, kwargs)
return self._request(POST, path, data=kwargs)

def _delete(self, path, **kwargs):
"""
Expand All @@ -829,9 +829,9 @@ def _delete(self, path, **kwargs):
Returns:
"""
return self._request(DELETE, path, kwargs)
return self._request(DELETE, path, params=kwargs)

def _request(self, verb, path, params):
def _request(self, verb, path, params={}, data={}):
"""
Executes HTTP request to API and handles response
Expand All @@ -851,7 +851,7 @@ def _request(self, verb, path, params):
headers = {'Accept': 'application/json; charset=utf-8'}

response = requests.request(
verb, url, allow_redirects=False, params=params, headers=headers,
verb, url, allow_redirects=False, params=params, data=data, headers=headers,
timeout=self.timeout)

log.debug('response %s: %s', response.status_code, repr(response.text))
Expand Down
6 changes: 4 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def assertRequestCalled(self, request, verb, url, **params):
kwargs = kwargs['params']
self.assertEqual(kwargs.pop('api_username'), self.api_username)
self.assertEqual(kwargs.pop('api_key'), self.api_key)
self.assertEqual(kwargs, params)

if verb == 'GET':
self.assertEqual(kwargs, params)



Expand Down Expand Up @@ -189,4 +191,4 @@ def test_badges(self, request):
def test_grant_badge_to(self, request):
prepare_response(request)
self.client.grant_badge_to('username', 1)
self.assertRequestCalled(request, 'POST', '/user_badges', username='username', badge_id=1)
self.assertRequestCalled(request, 'POST', '/user_badges', username='username', badge_id=1)

0 comments on commit 811453a

Please sign in to comment.