@@ -185,6 +185,51 @@ def test_null_element_id(self, mock_logging, mock_post):
185185 self .assertEqual (str (mock_logging .exception .call_args_list [0 ][0 ][2 ]),
186186 'element id is not set' )
187187
188+ @mock .patch ('netuitive.client.urllib2.urlopen' )
189+ @mock .patch ('netuitive.client.logging' )
190+ def test_kill_switch_410 (self , mock_logging , mock_post ):
191+
192+ mock_post .return_value = MockResponse (code = 410 )
193+
194+ a = netuitive .Client (api_key = 'apikey' )
195+ e = netuitive .Element ()
196+
197+ e .add_sample (
198+ 'nonsparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
199+
200+ resp = a .post (e )
201+ resp2 = a .post (e )
202+
203+ self .assertNotEqual (resp , True )
204+ self .assertNotEqual (resp2 , True )
205+
206+ self .assertTrue (a .disabled )
207+
208+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
209+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
210+
211+ @mock .patch ('netuitive.client.urllib2.urlopen' )
212+ @mock .patch ('netuitive.client.logging' )
213+ def test_kill_switch_418 (self , mock_logging , mock_post ):
214+
215+ mock_post .return_value = MockResponse (code = 418 )
216+
217+ a = netuitive .Client (api_key = 'apikey' )
218+ e = netuitive .Element ()
219+
220+ e .add_sample (
221+ 'nonsparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
222+
223+ resp = a .post (e )
224+ resp2 = a .post (e )
225+
226+ self .assertNotEqual (resp , True )
227+ self .assertNotEqual (resp2 , True )
228+ self .assertTrue (a .disabled )
229+
230+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
231+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
232+
188233 def tearDown (self ):
189234 pass
190235
@@ -232,6 +277,46 @@ def test_failure_general(self, mock_logging, mock_post):
232277 self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
233278 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
234279
280+ @mock .patch ('netuitive.client.urllib2.urlopen' )
281+ @mock .patch ('netuitive.client.logging' )
282+ def test_kill_switch_410 (self , mock_logging , mock_post ):
283+
284+ mock_post .return_value = MockResponse (code = 410 )
285+
286+ # test infrastructure endpoint url creation
287+ a = netuitive .Client (api_key = 'apikey' )
288+
289+ e = netuitive .Event (
290+ 'test' , 'INFO' , 'test event' , 'big old test message' , 'INFO' )
291+
292+ resp = a .post_event (e )
293+
294+ self .assertNotEqual (resp , True )
295+ self .assertTrue (a .disabled )
296+
297+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
298+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
299+
300+ @mock .patch ('netuitive.client.urllib2.urlopen' )
301+ @mock .patch ('netuitive.client.logging' )
302+ def test_kill_switch_418 (self , mock_logging , mock_post ):
303+
304+ mock_post .return_value = MockResponse (code = 418 )
305+
306+ # test infrastructure endpoint url creation
307+ a = netuitive .Client (api_key = 'apikey' )
308+
309+ e = netuitive .Event (
310+ 'test' , 'INFO' , 'test event' , 'big old test message' , 'INFO' )
311+
312+ resp = a .post_event (e )
313+
314+ self .assertNotEqual (resp , True )
315+ self .assertTrue (a .disabled )
316+
317+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
318+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
319+
235320 def tearDown (self ):
236321 pass
237322
0 commit comments