Esempio n. 1
0
 def test_raisingReactorProvides(self):
     """
     L{RaisingMemoryReactor} provides all of the attributes described by the
     interfaces it advertises.
     """
     raisingReactor = RaisingMemoryReactor()
     verifyObject(IReactorTCP, raisingReactor)
     verifyObject(IReactorSSL, raisingReactor)
     verifyObject(IReactorUNIX, raisingReactor)
Esempio n. 2
0
    def test_endpointListenFailure(self):
        """
        When an endpoint tries to listen on an already listening port, a
        C{CannotListenError} failure is errbacked.
        """
        factory = object()
        exception = error.CannotListenError('', 80, factory)
        mreactor = RaisingMemoryReactor(listenException=exception)

        ep, ignoredArgs, ignoredDest = self.createServerEndpoint(
            mreactor, factory)

        d = ep.listen(object())

        receivedExceptions = []

        def checkFailure(f):
            receivedExceptions.append(f.value)

        d.addErrback(checkFailure)

        self.assertEquals(receivedExceptions, [exception])
Esempio n. 3
0
    def test_endpointConnectFailure(self):
        """
        If an endpoint tries to connect to a non-listening port it gets
        a C{ConnectError} failure.
        """
        expectedError = error.ConnectError(string="Connection Failed")

        mreactor = RaisingMemoryReactor(connectException=expectedError)

        clientFactory = object()

        ep, ignoredArgs, ignoredDest = self.createClientEndpoint(
            mreactor, clientFactory)

        d = ep.connect(clientFactory)

        receivedExceptions = []

        def checkFailure(f):
            receivedExceptions.append(f.value)

        d.addErrback(checkFailure)

        self.assertEquals(receivedExceptions, [expectedError])