@@ -402,6 +402,10 @@ class TestClientCheckPost(unittest.TestCase):
402402 def setUp (self ):
403403 pass
404404
405+ def test_client_connection_timeout (self ):
406+ a = netuitive .Client (connection_timeout = 30 )
407+ self .assertEqual (a .connection_timeout , 30 )
408+
405409 @mock .patch ('netuitive.client.urllib2.urlopen' )
406410 @mock .patch ('netuitive.client.logging' )
407411 def test_success (self , mock_logging , mock_post ):
@@ -417,6 +421,9 @@ def test_success(self, mock_logging, mock_post):
417421
418422 self .assertTrue (resp )
419423
424+ args , kwargs = mock_post .call_args
425+ self .assertEqual (kwargs ['timeout' ], 5 )
426+
420427 self .assertEqual (mock_logging .exception .call_args_list , [])
421428
422429 @mock .patch ('netuitive.client.urllib2.urlopen' )
@@ -431,27 +438,11 @@ def test_failure_general_http(self, mock_logging, mock_post):
431438
432439 e = netuitive .Check ('check' , 'test' , 60 )
433440
434- resp = a .post_event (e )
435-
436- self .assertNotEqual (resp , True )
437-
438- self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][0 ], 'error posting payload to api ingest endpoint (%s): %s' )
439-
440- @mock .patch ('netuitive.client.urllib2.urlopen' )
441- @mock .patch ('netuitive.client.logging' )
442- def test_failure_general (self , mock_logging , mock_post ):
443- mock_post .side_effect = urllib2 .URLError ('something' )
444-
445- # test infrastructure endpoint url creation
446- a = netuitive .Client (api_key = 'apikey' )
447-
448- c = netuitive .Check ('check' , 'test' , 60 )
449-
450- resp = a .post_check (c )
441+ resp = a .post_check (e )
451442
452443 self .assertNotEqual (resp , True )
453444
454- self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][0 ], 'error posting payload to api ingest endpoint (%s): %s' )
445+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][0 ], 'HTTPError posting payload to api ingest endpoint (%s): %s' )
455446
456447 @mock .patch ('netuitive.client.urllib2.urlopen' )
457448 @mock .patch ('netuitive.client.logging' )
@@ -509,7 +500,7 @@ def test_not_kill_switch_504(self, mock_logging, mock_post):
509500 self .assertNotEqual (resp , True )
510501 self .assertFalse (resp2 )
511502 self .assertFalse (a .disabled )
512- self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][0 ], 'error posting payload to api ingest endpoint (%s): %s' )
503+ self .assertEqual (mock_logging .exception .call_args_list [0 ][0 ][0 ], 'HTTPError posting payload to api ingest endpoint (%s): %s' )
513504
514505 def tearDown (self ):
515506 pass
0 commit comments