'Test to validate that custom protocol handlers work with raw row results
Connect and validate that the normal protocol handler is used.
Re-Connect and validate that the custom protocol handler is used.
Re-Connect and validate that the normal protocol handler is used.
@since 2.7
@jira_ticket PYTHON-313
@expected_result custom protocol handler is invoked appropriately.
@test_category data_types:serialization'

def test_custom_raw_uuid_row_results(self):

    cluster = Cluster(protocol_version=PROTOCOL_VERSION)
    session = cluster.connect(keyspace='custserdes')
    session.row_factory = tuple_factory
    result = session.execute('SELECT    schema_version    FROM    system.local')
    uuid_type = result[0][0]
    self.assertEqual(type(uuid_type), uuid.UUID)
    session.client_protocol_handler = CustomTestRawRowType
    session.row_factory = tuple_factory
    result_set = session.execute('SELECT    schema_version    FROM    system.local')
    raw_value = result_set[0][0]
    self.assertTrue(isinstance(raw_value, binary_type))
    self.assertEqual(len(raw_value), 16)
    session.client_protocol_handler = ProtocolHandler
    result_set = session.execute('SELECT    schema_version    FROM    system.local')
    uuid_type = result_set[0][0]
    self.assertEqual(type(uuid_type), uuid.UUID)
    cluster.shutdown()
