'Test to ensure the callbacks are correcltly called and the connection
is returned when there is an OTO
@since 3.12
@jira_ticket PYTHON-630
@expected_result the connection is correctly returned to the pool
after an OTO, also the only the errback is called and not the callback
when the message finally arrives.
@test_category metadata'

def test_callbacks_and_pool_when_oto(self):

    start_and_prime_singledc()
    self.addCleanup(stop_simulacron)
    cluster = Cluster(protocol_version=PROTOCOL_VERSION, compression=False)
    session = cluster.connect()
    self.addCleanup(cluster.shutdown)
    query_to_prime = 'SELECT    *    from    testkesypace.testtable'
    server_delay = 2
    prime_query(query_to_prime, then={'delay_in_ms': (server_delay * 1000)})
    future = session.execute_async(query_to_prime, timeout=1)
    (callback, errback) = (Mock(name='callback'), Mock(name='errback'))
    future.add_callbacks(callback, errback)
    self.assertRaises(OperationTimedOut, future.result)
    assert_quiescent_pool_state(self, cluster)
    time.sleep((server_delay + 1))
    errback.assert_called_once()
    callback.assert_not_called()
