@@ -126,6 +126,37 @@ def test_failure_general_http(self, mock_logging, mock_post):
126126 self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
127127 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
128128
129+ @mock .patch ('netuitive.client.urllib2.urlopen' )
130+ @mock .patch ('netuitive.client.logging' )
131+ def test_repeat_failure_general_http (self , mock_logging , mock_post ):
132+
133+ a = netuitive .Client (api_key = 'apikey' )
134+
135+ e = netuitive .Element ()
136+
137+ e .add_sample (
138+ 'nonsparseDataStrategy' , 1434110794 , 1 , 'COUNTER' , host = 'hostname' )
139+
140+ errs = [403 , 429 , 503 , 404 , 503 , 204 , 307 , 302 , 405 , 413 ]
141+
142+ for i in range (a .max_post_errors ):
143+ mock_post .return_value = MockResponse (code = errs [i ])
144+ mock_post .side_effect = urllib2 .HTTPError (
145+ a .url , errs [i ], '' , {}, None )
146+
147+ resp = a .post (e )
148+
149+ resp = a .post (e )
150+ self .assertNotEqual (resp , True )
151+ self .assertFalse (resp )
152+
153+ self .assertFalse (a .disabled )
154+
155+ self .assertEqual (len (e .samples ), 0 )
156+
157+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][
158+ 0 ], 'error posting payload to api ingest endpoint (%s): %s' )
159+
129160 @mock .patch ('netuitive.client.urllib2.urlopen' )
130161 @mock .patch ('netuitive.client.logging' )
131162 def test_failure_general (self , mock_logging , mock_post ):
0 commit comments