@@ -251,6 +251,31 @@ def test_kill_switch_418(self, mock_logging, mock_post):
251251 self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
252252 0 ], 'Posting has been disabled.See previous errors for details.' )
253253
254+ @mock .patch ('netuitive.client.urllib2.urlopen' )
255+ @mock .patch ('netuitive.client.logging' )
256+ def test_not_kill_switch_504 (self , mock_logging , mock_post ):
257+
258+ mock_post .return_value = MockResponse (code = 504 )
259+
260+ a = netuitive .Client (api_key = 'apikey' )
261+ mock_post .side_effect = urllib2 .HTTPError (a .url , 504 , '' , {}, None )
262+
263+ e = netuitive .Element ()
264+
265+ e .add_sample (
266+ 'nonsparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
267+
268+ resp = a .post (e )
269+ resp2 = a .post (e )
270+
271+ self .assertNotEqual (resp , True )
272+ self .assertFalse (resp2 )
273+
274+ self .assertFalse (a .disabled )
275+
276+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
277+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
278+
254279 def tearDown (self ):
255280 pass
256281
@@ -359,6 +384,27 @@ def test_kill_switch_418(self, mock_logging, mock_post):
359384 self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
360385 0 ], 'Posting has been disabled.See previous errors for details.' )
361386
387+ @mock .patch ('netuitive.client.urllib2.urlopen' )
388+ @mock .patch ('netuitive.client.logging' )
389+ def test_not_kill_switch_504 (self , mock_logging , mock_post ):
390+
391+ mock_post .return_value = MockResponse (code = 504 )
392+ # test infrastructure endpoint url creation
393+ a = netuitive .Client (api_key = 'apikey' )
394+ mock_post .side_effect = urllib2 .HTTPError (a .url , 504 , '' , {}, None )
395+
396+ e = netuitive .Event (
397+ 'test' , 'INFO' , 'test event' , 'big old test message' , 'INFO' )
398+
399+ resp = a .post_event (e )
400+ resp2 = a .post_event (e )
401+
402+ self .assertNotEqual (resp , True )
403+ self .assertFalse (resp2 )
404+ self .assertFalse (a .disabled )
405+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
406+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
407+
362408 def tearDown (self ):
363409 pass
364410
0 commit comments