Ejemplo n.º 1
0
    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]))
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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([]))
Ejemplo n.º 4
0
    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