def test_serviceping_ping_open_https(self): result = ping('yahoo.com', port=443, https=True) self.assertIsInstance(result, PingResponse) self.assertTrue(result.responding) self.assertEqual(result.state, 'open') self.assertEqual(result.host, 'yahoo.com') self.assertEqual(result.port, 443)
def test_serviceping_ping_closed(self): result = ping('localhost', port=65500) self.assertIsInstance(result, PingResponse) self.assertIsInstance(result, PingResponse) self.assertFalse(result.responding) self.assertEqual(result.state, 'closed') self.assertEqual(result.host, 'localhost') self.assertEqual(result.port, 65500)
def test_serviceping_ping_open_https_url(self): result = ping( 'yahoo.com', port=443, https=True, url='https://yahoo.com/' ) self.assertIsInstance(result, PingResponse) self.assertTrue(result.responding) self.assertEqual(result.state, 'open') self.assertEqual(result.host, 'yahoo.com') self.assertEqual(result.port, 443) self.assertIn(result.code, [200, 301])
def test_serviceping_pingresponse__str__(self): result = ping('localhost', 65500) self.assertIn('ip=localhost(127.0.0.1):port=65500:responding=False:data_mismatch=False:timeout=False:duration=', str(result))