'Test for protocol negotiation
test_protocol_negotiation tests that the driver will select the correct protocol version to match
the correct cassandra version. Please note that 2.1.5 has a
bug https://issues.apache.org/jira/browse/CASSANDRA-9451 that will cause this test to fail
that will cause this to not pass. It was rectified in 2.1.6
@since 2.6.0
@jira_ticket PYTHON-240
@expected_result the correct protocol version should be selected
@test_category connection'

def test_protocol_negotiation(self):

    cluster = Cluster()
    self.assertLessEqual(cluster.protocol_version, cassandra.ProtocolVersion.MAX_SUPPORTED)
    session = cluster.connect()
    updated_protocol_version = session._protocol_version
    updated_cluster_version = cluster.protocol_version
    if (CASSANDRA_VERSION >= '2.2'):
        self.assertEqual(updated_protocol_version, 4)
        self.assertEqual(updated_cluster_version, 4)
    elif (CASSANDRA_VERSION >= '2.1'):
        self.assertEqual(updated_protocol_version, 3)
        self.assertEqual(updated_cluster_version, 3)
    elif (CASSANDRA_VERSION >= '2.0'):
        self.assertEqual(updated_protocol_version, 2)
        self.assertEqual(updated_cluster_version, 2)
    else:
        self.assertEqual(updated_protocol_version, 1)
        self.assertEqual(updated_cluster_version, 1)
    cluster.shutdown()
