[apt-proxy-devel] r666 - trunk/apt_proxy/test
Chris Halls
halls at alioth.debian.org
Fri Jul 13 11:16:56 UTC 2007
Author: halls
Date: Fri Jul 13 11:16:56 2007
New Revision: 666
Log:
* Fix test exception
* Add test client early disconnect
Modified:
trunk/apt_proxy/test/test_requests.py
Modified: trunk/apt_proxy/test/test_requests.py
==============================================================================
--- trunk/apt_proxy/test/test_requests.py (original)
+++ trunk/apt_proxy/test/test_requests.py Fri Jul 13 11:16:56 2007
@@ -18,7 +18,7 @@
import os, time, urllib
from twisted.trial import unittest
-from twisted.internet import protocol, reactor, defer
+from twisted.internet import protocol, reactor, defer, base
from twisted.python import failure
from twisted import web
from twisted.web import http
@@ -32,6 +32,8 @@
from apt_proxy.test.test_fetchers import RsyncServer
from apt_proxy.test.test_apt_proxy import apTestHelper
+base.DelayedCall.debug = True
+
class uriData:
"""
class containing test data for a request
@@ -485,14 +487,16 @@
d = self.doRequest(uriData(filename, http.INTERNAL_SERVER_ERROR))
d.addBoth(restoreException)
d.addCallback(self.DownloadQueueException2)
- reactor.callLater(2, self.DownloadQueueExceptionTimeout) # timeout will trigger errorBack if necessary
+ self.timer = reactor.callLater(2, self.DownloadQueueExceptionTimeout) # timeout will trigger errorBack if necessary
return self.testResult
def DownloadQueueException2(self, x):
queues = self.factory.getBackend(self.backendName).queue.queues.values()
self.assertEquals(len(queues), 0)
log.debug("disconnecting")
self.connection.disconnect()
- self.testResult.callback()
+ self.timer.cancel()
+ log.debug("test result callback")
+ self.testResult.callback(None)
def DownloadQueueExceptionTimeout(self):
DownloadQueue.addFile = self.fnsave
log.debug("testDownloadQueueException: timed out")
@@ -576,6 +580,24 @@
self.testResult.callback(None)
testAbort.timeout = 2
testAbort.todo = "Test not yet working"
+ def testClientDisconnect(self):
+ "Test cleanup if client disconnects before data is sent"
+ self.testResult = defer.Deferred()
+ b = self.factory.getBackend(self.backendName)
+ b.config.bandwidth_limit = 10
+ filename, sourcepath, destpath = self.getFilePaths('/packages/apt_0.0.1_test.deb')
+ d = self.doRequest(uriData(filename, http.OK, filePath=sourcepath, abortTransfer=True))
+ d.addCallback(self.ClientDisconnect2)
+ d.addErrback(lambda x: self.testResult.errback(failure.Failure(self.UnknownFailure)))
+ return self.testResult
+ def ClientDisconnect2(self, x):
+ "Connection was aborted, check that fetchers were closed"
+ log.debug("testClientDisconnect2", self.debugname)
+ #backendQueues = self.factory.getBackend(self.backendName).queue.queues
+ #self.assertEquals(len(backendQueues), 0)
+ log.debug("testAbort2a", self.debugname)
+ self.testResult.callback(None)
+ testClientDisconnect.timeout = 2
# This test does not work with current twisted http client :(
#def testPipeline(self):
More information about the apt-proxy-devel
mailing list