'Test to ensure that CL is set correctly honored when executing trace queries.
@since 3.3
@jira_ticket PYTHON-435
@expected_result Consistency Levels set on get_query_trace should be honored'

def test_trace_cl(self):

    query = 'SELECT    *    FROM    system.local'
    statement = SimpleStatement(query)
    response_future = self.session.execute_async(statement, trace=True)
    response_future.result()
    with self.assertRaises(Unavailable):
        response_future.get_query_trace(query_cl=ConsistencyLevel.THREE)
    self.assertIsNotNone(response_future.get_query_trace(max_wait=2.0, query_cl=ConsistencyLevel.TWO).trace_id)
    response_future = self.session.execute_async(statement, trace=True)
    response_future.result()
    self.assertIsNotNone(response_future.get_query_trace(max_wait=2.0, query_cl=ConsistencyLevel.ONE).trace_id)
    response_future = self.session.execute_async(statement, trace=True)
    response_future.result()
    with self.assertRaises(InvalidRequest):
        self.assertIsNotNone(response_future.get_query_trace(max_wait=2.0, query_cl=ConsistencyLevel.ANY).trace_id)
    self.assertIsNotNone(response_future.get_query_trace(max_wait=2.0, query_cl=ConsistencyLevel.QUORUM).trace_id)
