def test_connect_cancels_existing_timeout_call(self):
     prober = ProberFactory(self.urls['200'])
     prober.timeoutCall = reactor.callLater(30, prober.failWithTimeoutError)
     old_timeout_call = prober.timeoutCall
     self.failUnless(old_timeout_call.active())
     prober.connect()
     self.failIf(old_timeout_call.active())
     self.failUnless(prober.timeoutCall.active())
     return prober._deferred
 def test_connect_cancels_existing_timeout_call(self):
     prober = ProberFactory(self.urls['200'])
     prober.timeoutCall = reactor.callLater(
         30, prober.failWithTimeoutError)
     old_timeout_call = prober.timeoutCall
     self.failUnless(old_timeout_call.active())
     prober.connect()
     self.failIf(old_timeout_call.active())
     self.failUnless(prober.timeoutCall.active())
     return prober._deferred
    def _createProberStubConnectAndProbe(self, requests, timeouts):
        """Create a ProberFactory object with a URL inside self.host and call
        its probe() method.

        Before the prober.probe() method is called, we stub the connect
        method, because all we want is to check whether that method was called
        or not --we don't want to actually connect.
        """
        def connect():
            prober.connectCalled = True
        distributionmirror_prober.host_requests = {self.host: requests}
        distributionmirror_prober.host_timeouts = {self.host: timeouts}
        prober = ProberFactory('http://%s/baz' % self.host)
        prober.connectCalled = False
        prober.failed = lambda error: None
        prober.connect = connect
        prober.probe()
        return prober
    def _createProberStubConnectAndProbe(self, requests, timeouts):
        """Create a ProberFactory object with a URL inside self.host and call
        its probe() method.

        Before the prober.probe() method is called, we stub the connect
        method, because all we want is to check whether that method was called
        or not --we don't want to actually connect.
        """
        def connect():
            prober.connectCalled = True

        distributionmirror_prober.host_requests = {self.host: requests}
        distributionmirror_prober.host_timeouts = {self.host: timeouts}
        prober = ProberFactory('http://%s/baz' % self.host)
        prober.connectCalled = False
        prober.failed = lambda error: None
        prober.connect = connect
        prober.probe()
        return prober