'When a connection is made by the C{ProxyAgent}, it uses its pool\'s
C{getConnection} method to do so, with the endpoint it was constructed
with and a key of C{("http-proxy", endpoint)}.'

def test_connectUsesConnectionPool(self):

    endpoint = DummyEndpoint()
    class DummyPool(object, ):
        connected = False
        persistent = False
        def getConnection(this, key, ep):
            this.connected = True
            self.assertIdentical(ep, endpoint)
            self.assertEqual(key, ('http-proxy', endpoint))
            return defer.succeed(StubHTTPProtocol())
    pool = DummyPool()
    agent = client.ProxyAgent(endpoint, self.reactor, pool=pool)
    self.assertIdentical(pool, agent._pool)
    agent.request('GET', 'http://foo/')
    self.assertEqual(agent._pool.connected, True)
