def test_clientBusyAddsNewClient(self): """ Test that a client not in the free set gets added to the busy set. """ p = MemCacheClientFactory().buildProtocol(None) self.pool.clientBusy(p) self.assertEquals(self.pool._busyClients, set([p]))
def setUp(self): """ Create a L{MemCacheClientFactory} instance and and give it a L{StubConnectionPool} instance. """ super(MemCacheClientFactoryTests, self).setUp() self.pool = StubConnectionPool() self.factory = MemCacheClientFactory() self.factory.connectionPool = self.pool self.protocol = self.factory.buildProtocol(None)
def test_clientGoneRemovesBusyClient(self): """ Test that a client in the busy set gets removed when L{MemCachePool.clientGone} is called. """ p = MemCacheClientFactory().buildProtocol(None) self.pool.clientBusy(p) self.assertEquals(self.pool._busyClients, set([p])) self.assertEquals(self.pool._freeClients, set([])) self.pool.clientGone(p) self.assertEquals(self.pool._busyClients, set([]))
def test_connectionMadeFiresDeferred(self): """ Test that L{PooledMemCacheProtocol.connectionMade} fires the factory's deferred. """ p = PooledMemCacheProtocol() p.factory = MemCacheClientFactory() p.connectionPool = StubConnectionPool() d = p.factory.deferred d.addCallback(self.assertEquals, p) p.connectionMade() return d