'Test to validate that timeouts are honored
Exercise the underlying timeouts, by attempting a query that will timeout. Ensure the default timeout is still
honored. Make sure that user timeouts are also honored.
@since 2.7.0
@jira_ticket PYTHON-108
@expected_result timeouts should be honored
@test_category'

def test_async_timeouts(self):

    ss = SimpleStatement('SELECT    *    FROM    test3rf.test', consistency_level=ConsistencyLevel.ALL)
    start_time = time.time()
    future = self.session.execute_async(ss)
    with self.assertRaises(OperationTimedOut):
        future.result()
    end_time = time.time()
    total_time = (end_time - start_time)
    expected_time = self.session.default_timeout
    self.assertAlmostEqual(expected_time, total_time, delta=0.05)
    start_time = time.time()
    future = self.session.execute_async(ss, timeout=1)
    mock_callback = Mock(return_value=None)
    mock_errorback = Mock(return_value=None)
    future.add_callback(mock_callback)
    future.add_errback(mock_errorback)
    with self.assertRaises(OperationTimedOut):
        future.result()
    end_time = time.time()
    total_time = (end_time - start_time)
    expected_time = 1
    self.assertAlmostEqual(expected_time, total_time, delta=0.05)
    self.assertTrue(mock_errorback.called)
    self.assertFalse(mock_callback.called)
