Python twisted.internet.interfaces.IConnector() Examples

The following are 12 code examples of twisted.internet.interfaces.IConnector(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.internet.interfaces , or try the search function .
Example #1
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 6 votes vote down vote up
def test_connectStartsConnection(self):
        """
        When used with a successful endpoint, L{connect} will simulate all
        aspects of the connection process; C{buildProtocol}, C{connectionMade},
        C{dataReceived}.
        """
        self.assertIdentical(self.connector.getDestination(), self.endpoint)
        verifyObject(IConnector, self.connector)
        self.assertEqual(self.factory.starts, [self.connector])
        self.assertEqual(len(self.endpoint.attempts), 1)
        self.assertEqual(len(self.factory.built), 0)
        transport = self.connectionSucceeds()
        self.assertEqual(len(self.factory.built), 1)
        made = transport.protocol.made
        self.assertEqual(len(made), 1)
        self.assertIdentical(made[0], transport) 
Example #2
Source File: connectionmixins.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_interface(self):
        """
        The C{connect} method returns an object providing L{IConnector}.
        """
        reactor = self.buildReactor()
        connector = self.connect(reactor, ClientFactory())
        self.assertTrue(verifyObject(IConnector, connector)) 
Example #3
Source File: test_srvconnect.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_interface(self):
        """
        L{srvconnect.SRVConnector} implements L{IConnector}.
        """
        verifyObject(IConnector, self.connector) 
Example #4
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_disconnectWhileConnecting(self):
        """
        When the L{IConnector} is told to C{disconnect} before an in-progress
        L{Deferred} from C{connect} has fired, it will cancel that L{Deferred}.
        """
        self.connector.disconnect()
        self.assertEqual(len(self.factory.fails), 1)
        self.assertTrue(self.factory.fails[0].reason.check(CancelledError)) 
Example #5
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_disconnectWhileConnected(self):
        """
        When the L{IConnector} is told to C{disconnect} while an existing
        connection is established, that connection will be dropped via
        C{loseConnection}.
        """
        transport = self.connectionSucceeds()
        self.factory.starts[0].disconnect()
        self.assertEqual(transport.lose, [transport]) 
Example #6
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_connectAfterFailure(self):
        """
        When the L{IConnector} is told to C{connect} after a connection attempt
        has failed, a new connection attempt is started.
        """
        why = Failure(ZeroDivisionError())
        self.connectionFails(why)
        self.connector.connect()
        self.assertEqual(len(self.factory.starts), 2)
        self.assertEqual(len(self.endpoint.attempts), 2)
        self.connectionSucceeds() 
Example #7
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_reConnectTooSoon(self):
        """
        When the L{IConnector} is told to C{connect} while another attempt is
        still in flight, it synchronously raises L{RuntimeError}.
        """
        self.assertRaises(RuntimeError, self.connector.connect)
        self.assertEqual(len(self.factory.starts), 1)
        self.assertEqual(len(self.endpoint.attempts), 1) 
Example #8
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_stopConnectingWhileConnected(self):
        """
        When the L{IConnector} is told to C{stopConnecting} while already
        connected, it raises a L{RuntimeError}.
        """
        self.connectionSucceeds()
        self.assertRaises(RuntimeError, self.connector.stopConnecting) 
Example #9
Source File: test_adaptendpoint.py    From ccs-twistedextensions with Apache License 2.0 5 votes vote down vote up
def test_stopConnectingWhileNotConnected(self):
        """
        When the L{IConnector} is told to C{stopConnecting} while it is not
        connected or connecting, it raises L{RuntimeError}.
        """
        self.connectionFails(Failure(ZeroDivisionError()))
        self.assertRaises(RuntimeError, self.connector.stopConnecting) 
Example #10
Source File: connectionmixins.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_interface(self):
        """
        The C{connect} method returns an object providing L{IConnector}.
        """
        reactor = self.buildReactor()
        connector = self.connect(reactor, ClientFactory())
        self.assertTrue(verifyObject(IConnector, connector)) 
Example #11
Source File: test_srvconnect.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_interface(self):
        """
        L{srvconnect.SRVConnector} implements L{IConnector}.
        """
        verifyObject(IConnector, self.connector) 
Example #12
Source File: test_unix.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_interface(self):
        """
        L{IReactorUNIX.connectUNIX} returns an object providing L{IConnector}.
        """
        reactor = self.buildReactor()
        connector = reactor.connectUNIX(self.mktemp(), ClientFactory())
        self.assertTrue(verifyObject(IConnector, connector))