'The callable passed as the value for the C{pumpPolicy} parameter to
L{loopbackAsync} is called with a L{_LoopbackQueue} of pending bytes
and a protocol to which they should be delivered.'

def test_pumpPolicy(self):

    pumpCalls = []
    def dummyPolicy(queue, target):
        bytes = []
        while queue:
            bytes.append(queue.get())
        pumpCalls.append((target, bytes))
    client = Protocol()
    server = Protocol()
    finished = loopback.loopbackAsync(server, client, dummyPolicy)
    self.assertEqual(pumpCalls, [])
    client.transport.write('foo')
    client.transport.write('bar')
    server.transport.write('baz')
    server.transport.write('quux')
    server.transport.loseConnection()
    def cbComplete(ignored):
        self.assertEqual(pumpCalls, [(client, ['baz', 'quux', None]), (server, ['foo', 'bar'])])
    finished.addCallback(cbComplete)
    return finished
