File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -400,3 +400,29 @@ def test_publish_should_raise_on_http_404_error(self):
400
400
},
401
401
)
402
402
self .assertIn ('Instance not found: blah' , str (e .exception ))
403
+
404
+
405
+ def test_publish_should_error_correctly_if_error_not_json (self ):
406
+ pn_client = PushNotifications (
407
+ 'INSTANCE_ID' ,
408
+ 'SECRET_KEY'
409
+ )
410
+ with requests_mock .Mocker () as http_mock :
411
+ http_mock .register_uri (
412
+ requests_mock .ANY ,
413
+ requests_mock .ANY ,
414
+ status_code = 500 ,
415
+ text = '<notjson></notjson>' ,
416
+ )
417
+ with self .assertRaises (PusherServerError ) as e :
418
+ pn_client .publish (
419
+ interests = ['donuts' ],
420
+ publish_body = {
421
+ 'apns' : {
422
+ 'aps' : {
423
+ 'alert' : 'Hello World!' ,
424
+ },
425
+ },
426
+ },
427
+ )
428
+ self .assertIn ('Unknown error: no description' , str (e .exception ))
You can’t perform that action at this time.
0 commit comments