From: Cameron Dale Date: Fri, 9 May 2008 21:41:36 +0000 (-0700) Subject: Tests for some more HTTP connection errors. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b6a087a2e59561b24f6e1935386066c3d0746098;p=quix0rs-apt-p2p.git Tests for some more HTTP connection errors. --- diff --git a/apt_p2p/HTTPDownloader.py b/apt_p2p/HTTPDownloader.py index 9e789b8..3e6eaa3 100644 --- a/apt_p2p/HTTPDownloader.py +++ b/apt_p2p/HTTPDownloader.py @@ -589,6 +589,32 @@ class TestClientManager(unittest.TestCase): d.addCallback(lambda a: self.flushLoggedErrors(TimeoutError)) return d + def test_dnserror(self): + """Tests a connection timeout.""" + from twisted.internet.error import DNSLookupError + host = 'hureyfnvbfha.debian.net' + self.client = Peer(host, 80) + self.timeout = 10 + + d = self.client.get('/rfc/rfc0013.txt') + d.addCallback(self.gotResp, 1, 1070) + d = self.failUnlessFailure(d, DNSLookupError) + d.addCallback(lambda a: self.flushLoggedErrors(DNSLookupError)) + return d + + def test_noroute(self): + """Tests a connection timeout.""" + from twisted.internet.error import NoRouteError + host = '1.2.3.4' + self.client = Peer(host, 80) + self.timeout = 60 + + d = self.client.get('/rfc/rfc0013.txt') + d.addCallback(self.gotResp, 1, 1070) + d = self.failUnlessFailure(d, NoRouteError) + d.addCallback(lambda a: self.flushLoggedErrors(NoRouteError)) + return d + def tearDown(self): for p in self.pending_calls: if p.active():