@@ -436,6 +436,24 @@ def test_trigger_failsafe(self, post, _send_failsafe):
436436 rollbar .report_exc_info ()
437437 self .assertEqual (_send_failsafe .call_count , 2 )
438438
439+ @mock .patch ('rollbar._send_failsafe' )
440+ @mock .patch ('rollbar.lib.transport.post' ,
441+ side_effect = lambda * args , ** kw : MockRawResponse ('<html>\r \n ' \
442+ '<head><title>502 Bad Gateway</title></head>\r \n ' \
443+ '<body bgcolor="white">\r \n ' \
444+ '<center><h1>502 Bad Gateway</h1></center>\r \n ' \
445+ '<hr><center>nginx</center>\r \n ' \
446+ '</body>\r \n ' \
447+ '</html>\r \n ' , 502 ))
448+ def test_502_failsafe (self , post , _send_failsafe ):
449+ rollbar .report_message ('derp' )
450+ # self.assertEqual(_send_failsafe.call_count, 1)
451+
452+ try :
453+ raise Exception ('trigger_failsafe' )
454+ except :
455+ rollbar ._post_api ('/api/1/item' , {'derp' })
456+
439457 @mock .patch ('rollbar.send_payload' )
440458 def test_send_failsafe (self , send_payload ):
441459 test_uuid = str (uuid .uuid4 ())
@@ -1217,6 +1235,19 @@ def content(self):
12171235 def json (self ):
12181236 return self .json_data
12191237
1238+
1239+ class MockRawResponse :
1240+ def __init__ (self , data , status_code ):
1241+ self .data = data
1242+ self .status_code = status_code
1243+
1244+ @property
1245+ def content (self ):
1246+ return self .data
1247+
1248+ def json (self ):
1249+ return self .data
1250+
12201251class MockLambdaContext (object ):
12211252 def __init__ (self , x ):
12221253 self .function_name = 1
0 commit comments