def test_connect(self): reactor = MemoryReactorClock() reactor.running = True c = KafkaBrokerClient('test_connect', reactor=reactor) c._connect() # Force a connection attempt c.connector.factory = c # MemoryReactor doesn't make this connection. # Build the protocol, like a real connector would c.buildProtocol(None) reactor.advance(1.0) # Trigger the DelayedCall to _notify
def test_connect(self): reactor = MemoryReactorClock() reactor.running = True c = KafkaBrokerClient('test_connect', reactor=reactor) c._connect() # Force a connection attempt c.connector.factory = c # MemoryReactor doesn't make this connection. # Let's pretend we've connected, which will schedule the firing c.buildProtocol(None) reactor.advance(1.0)
def test_connected(self): reactor = MemoryReactorClock() reactor.running = True c = KafkaBrokerClient(reactor, 'test_connect', 9092, 'clientId') c._connect() # Force a connection attempt c.connector.factory = c # MemoryReactor doesn't make this connection. self.assertFalse(c.connected()) # Build the protocol, like a real connector would c.buildProtocol(None) self.assertTrue(c.connected()) reactor.advance(1.0) # Trigger the DelayedCall to _notify
def test_connect(self): reactor = MemoryReactorClock() reactor.running = True c = KafkaBrokerClient(reactor, 'kafka.example.com', 9092, 'clientId') c._connect() # Force a connection attempt c.connector.factory = c # MemoryReactor doesn't make this connection. # Build the protocol, like a real connector would addr = IPv4Address('TCP', '1.2.3.4', 9092) c.buildProtocol(addr) self.assertEqual(("<KafkaBrokerClient kafka.example.com:9092 " "clientId='clientId' connected>"), repr(c))