Skip to content

Commit 102e4ab

Browse files
committed
[Client] Fix: send json data as json
1 parent e66c9d4 commit 102e4ab

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented here.
44

5+
## [0.2.2] - 2019-07-12
6+
### Fixed
7+
- Send json data actually as json.
8+
59
## [0.2.1] - 2019-07-08
610
### Fixed
711
- Object creation when requesting a single object.

helpscout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from helpscout.client import HelpScout # noqa
22

33

4-
__version__ = '0.2.1'
4+
__version__ = '0.2.2'

helpscout/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def hit(self, endpoint, method, resource_id=None, data=None, params=None):
137137
params = '&'.join('%s=%s' % (k, v) for k, v in params.items())
138138
url = '%s?%s' % (url, params)
139139
headers = self._authentication_headers()
140-
r = getattr(requests, method)(url, headers=headers, data=data)
140+
r = getattr(requests, method)(url, headers=headers, json=data)
141141
logger.debug('%s %s' % (method, url))
142142
ok, status_code = r.ok, r.status_code
143143
if status_code in (201, 204):

tests/helpscout/test_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_hit_no_access_token_ok(self):
103103
auth_headers.assert_called_once()
104104
logger.debug.assert_called_once_with(method + ' ' + full_url)
105105
requests.get.assert_called_once_with(
106-
full_url, headers=headers, data=None)
106+
full_url, headers=headers, json=None)
107107
response.json.assert_called_once()
108108
pages.assert_called_once_with(json_response, method)
109109

@@ -128,7 +128,7 @@ def test_hit_ok(self):
128128
auth_headers.assert_called_once()
129129
logger.debug.assert_called_once_with(method + ' ' + full_url)
130130
requests.get.assert_called_once_with(
131-
full_url, headers=headers, data=None)
131+
full_url, headers=headers, json=None)
132132
response.json.assert_called_once()
133133
pages.assert_called_once_with(json_response, method)
134134

@@ -153,7 +153,7 @@ def test_hit_resource_id_ok(self):
153153
auth_headers.assert_called_once()
154154
logger.debug.assert_called_once_with(method + ' ' + full_url)
155155
requests.get.assert_called_once_with(
156-
full_url, headers=headers, data=None)
156+
full_url, headers=headers, json=None)
157157
response.json.assert_called_once()
158158
pages.assert_called_once_with(json_response, method)
159159

@@ -179,7 +179,7 @@ def test_hit_params_dict_ok(self):
179179
auth_headers.assert_called_once()
180180
logger.debug.assert_called_once_with(method + ' ' + full_url)
181181
requests.get.assert_called_once_with(
182-
full_url, headers=headers, data=None)
182+
full_url, headers=headers, json=None)
183183
response.json.assert_called_once()
184184
pages.assert_called_once_with(json_response, method)
185185

@@ -205,7 +205,7 @@ def test_hit_resource_id_with_params_dict_ok(self):
205205
auth_headers.assert_called_once()
206206
logger.debug.assert_called_once_with(method + ' ' + full_url)
207207
requests.get.assert_called_once_with(
208-
full_url, headers=headers, data=None)
208+
full_url, headers=headers, json=None)
209209
response.json.assert_called_once()
210210
pages.assert_called_once_with(json_response, method)
211211

@@ -232,7 +232,7 @@ def test_hit_resource_id_with_params_str_ok(self):
232232
auth_headers.assert_called_once()
233233
logger.debug.assert_called_once_with(method + ' ' + full_url)
234234
requests.get.assert_called_once_with(
235-
full_url, headers=headers, data=None)
235+
full_url, headers=headers, json=None)
236236
response.json.assert_called_once()
237237
pages.assert_called_once_with(json_response, method)
238238

@@ -258,7 +258,7 @@ def test_hit_post_ok(self):
258258
auth_headers.assert_called_once()
259259
logger.debug.assert_called_once_with(method + ' ' + full_url)
260260
requests.post.assert_called_once_with(
261-
full_url, headers=headers, data=None)
261+
full_url, headers=headers, json=None)
262262
response.json.assert_not_called()
263263
pages.assert_not_called()
264264
self.assertEqual(ret, [None])
@@ -285,7 +285,7 @@ def test_hit_delete_ok(self):
285285
auth_headers.assert_called_once()
286286
logger.debug.assert_called_once_with(method + ' ' + full_url)
287287
requests.delete.assert_called_once_with(
288-
full_url, headers=headers, data=None)
288+
full_url, headers=headers, json=None)
289289
response.json.assert_not_called()
290290
pages.assert_not_called()
291291
self.assertEqual(ret, [None])
@@ -312,7 +312,7 @@ def test_hit_patch_ok(self):
312312
auth_headers.assert_called_once()
313313
logger.debug.assert_called_once_with(method + ' ' + full_url)
314314
requests.patch.assert_called_once_with(
315-
full_url, headers=headers, data=None)
315+
full_url, headers=headers, json=None)
316316
response.json.assert_not_called()
317317
pages.assert_not_called()
318318
self.assertEqual(ret, [None])
@@ -341,7 +341,7 @@ def test_hit_token_expired(self):
341341
[call(method + ' ' + full_url) for _ in range(2)])
342342
self.assertEqual(
343343
requests.get.call_args_list,
344-
[call(full_url, headers=headers, data=None) for _ in range(2)])
344+
[call(full_url, headers=headers, json=None) for _ in range(2)])
345345
response.json.assert_called_once()
346346
pages.assert_called_once_with(json_response, method)
347347
auth.assert_called_once()
@@ -371,7 +371,7 @@ def test_hit_rate_limit_exceeded(self):
371371
[call(method + ' ' + full_url) for _ in range(2)])
372372
self.assertEqual(
373373
requests.get.call_args_list,
374-
[call(full_url, headers=headers, data=None) for _ in range(2)])
374+
[call(full_url, headers=headers, json=None) for _ in range(2)])
375375
response.json.assert_called_once()
376376
pages.assert_called_once_with(json_response, method)
377377
rate_limit.assert_called_once()
@@ -402,7 +402,7 @@ def test_hit_exception(self):
402402
auth_headers.assert_called_once()
403403
logger.debug.assert_called_once_with(method + ' ' + full_url)
404404
requests.get.assert_called_once_with(
405-
full_url, headers=headers, data=None)
405+
full_url, headers=headers, json=None)
406406
response.json.assert_not_called()
407407
pages.assert_not_called()
408408
rate_limit.assert_not_called()

0 commit comments

Comments
 (0)