From b6a087a2e59561b24f6e1935386066c3d0746098 Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Fri, 9 May 2008 14:41:36 -0700 Subject: [PATCH] Tests for some more HTTP connection errors. --- apt_p2p/HTTPDownloader.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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(): -- 2.39.5