@@ -224,3 +224,35 @@ def it_raises_a_multiple_matching_users_error(self):
224
224
mock_method .return_value = resp
225
225
with assert_raises (intercom .MultipleMatchingUsersError ):
226
226
Intercom .get ('/users' )
227
+
228
+ @istest
229
+ def it_handles_empty_responses (self ):
230
+ resp = mock_response ('' , status_code = 202 )
231
+ with patch ('requests.request' ) as mock_method :
232
+ mock_method .return_value = resp
233
+ Request .send_request_to_path ('GET' , 'events' , ('x' , 'y' ), resp )
234
+
235
+ resp = mock_response (' ' , status_code = 202 )
236
+ with patch ('requests.request' ) as mock_method :
237
+ mock_method .return_value = resp
238
+ Request .send_request_to_path ('GET' , 'events' , ('x' , 'y' ), resp )
239
+
240
+ @istest
241
+ def it_handles_no_encoding (self ):
242
+ resp = mock_response (
243
+ ' ' , status_code = 200 , encoding = None , headers = None )
244
+ resp .apparent_encoding = 'utf-8'
245
+
246
+ with patch ('requests.request' ) as mock_method :
247
+ mock_method .return_value = resp
248
+ Request .send_request_to_path ('GET' , 'events' , ('x' , 'y' ), resp )
249
+
250
+ @istest
251
+ def it_needs_encoding_or_apparent_encoding (self ):
252
+ resp = mock_response (
253
+ '{}' , status_code = 200 , encoding = None , headers = None )
254
+
255
+ with patch ('requests.request' ) as mock_method :
256
+ mock_method .return_value = resp
257
+ with assert_raises (TypeError ):
258
+ Request .send_request_to_path ('GET' , 'events' , ('x' , 'y' ), resp )
0 commit comments